Insert one week dates ahead of last enter date

apprentice

Registered User.
Local time
Yesterday, 23:21
Joined
Jan 13, 2015
Messages
27
I would like to enter a week dates forward after looking up the last entered date. i have working codes that looks up the last date and increments it by one and enter the date into a new field.

Here is what i have:

Private Sub Form_AfterUpdate()
Dim dtmNextDate As Date
Dim dtmLastDate As Date
Dim SDate As Date

LastDate = Nz(DMax("[SDate]", "schedule"), _
DateAdd("d", -1, Date))

NextDate = DateAdd("d", 1, LastDate)

CurrentDb.Execute "INSERT INTO Schedule(SDate) VALUES ('" & NextDate & "');"

End Sub

can you help me to enter dates into 5 new fields instead of one using a loop maybe.

thank you
 
Code:
 dim lastDate as Date
 dim i as integer
  
 LastDate = Nz(DMax("[SDate]", "schedule")

 for i=1 to 5
      CurrentDb.Execute "INSERT INTO Schedule(SDate) VALUES (" & dateadd("d",i,LastDate) & ")"
next i
 
codes does not work
 
i will like for the five entries the dates will be incremented by 1.
example; 1/23/2014
1/24/2014
1/25/2014
1/26/2014
 
thank very much. i just added the loop at the beginning of the code and it worked fine
 

Users who are viewing this thread

Back
Top Bottom