Hi,
I am trying to increment dates by one day in a loop, but I keep getting a Type Mismatch Error.
Here is the code:-
IncrementDate = "#" & [Forms]![frm_Schedule]![txt_StartDate] + 1 & "#"
Do Until IncrementDate = EndDate
sqlDaily = "INSERT INTO tbl_Schedules (ID_Date, ID_SchedData)" & _
"VALUES (" & IncrementDate & ", " & IdSchedData & ");"
CurrentDb.Execute sqlDaily
IncrementDate = IncrementDate +1
IncrementDate = DateAdd("d",1, IncrementDate)
Loop
The first line updates the initial start date by one day, then goes into the loop. The CurrentDB.Execute works fine, but the code
errors at IncrementDate = IncrementDate +1 or DateAdd. I tried wrapping it with ## but always errors.
Can someone please show me the error of my ways! :-S
Many thanks.
I am trying to increment dates by one day in a loop, but I keep getting a Type Mismatch Error.
Here is the code:-
IncrementDate = "#" & [Forms]![frm_Schedule]![txt_StartDate] + 1 & "#"
Do Until IncrementDate = EndDate
sqlDaily = "INSERT INTO tbl_Schedules (ID_Date, ID_SchedData)" & _
"VALUES (" & IncrementDate & ", " & IdSchedData & ");"
CurrentDb.Execute sqlDaily
IncrementDate = IncrementDate +1
IncrementDate = DateAdd("d",1, IncrementDate)
Loop
The first line updates the initial start date by one day, then goes into the loop. The CurrentDB.Execute works fine, but the code
errors at IncrementDate = IncrementDate +1 or DateAdd. I tried wrapping it with ## but always errors.
Can someone please show me the error of my ways! :-S
Many thanks.