Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform increment function

Status
Not open for further replies.

Mindmaster

IS-IT--Management
Dec 6, 2001
17
0
0
GB

I am trying to right a piece of code for subform that will keep producing records in a sub until the date matches that which is in a box on the main form. The date however must be repeated in 7 day intervals from to days date for example:

if todays date = 1/12/01
and the text box = 28/12/01

record
1 07/12/01
2 14/12/01
3 21/12/01
4 28/12/01

i have other fields in the records that contain defaulted calculations however i dont want to have to return on each line i just want the records to be created automatically but and i need to trigger this function by a comand button on the main form....

i have been dealing with this problem for quiet some time and if i don't sort it today i'm in big trouble please take a look at your code libarys or functions and see if you have anything i can manipulate..

Thanks and streesed

rob

 
Hope this arrives in time to help.

Let me know if it works..Or if it doesn't make sense.
-------
Private Sub Command2_Click()

Dim dat1 As Date, dat2 As Date, i As Integer
Dim rst As Recordset, Diff

Set rst = CurrentDb.OpenRecordset("Table1")
dat1 = Date
Diff = Me.txtDate - dat1
For i = 7 To Diff Step 7
With rst
.AddNew
!DateF = dat1 + i
.Update
Debug.Print dat2
End With
Next
Me.Refresh

End Sub
-------
Me.txtDate is on the main form.
Table1 is the data on the SubForm.
Good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top