I am converting a MS ACCESS 2003 DB to MS ACCESS 2007, within the loop below, I'm setting holddate to a date the user selects. I am then counting up to a week within the loop. Meanwhile I'm taking that same date (holdDate) and extracting the day and inputting the values in a table. It works perfectly fine in Access 2003, but not in 2007. Can anyone please tell me what is wrong and where is the difference? Thanks.
Do While intReportDays < 7
'is hold date a weekend day
If (DatePart("w", [holdDate]) = 1) Then
holdDate = DateAdd("y", 1, holdDate) 'Add one day to holddate
Else 'is hold date a holiday
Set Myset = MyDB.OpenRecordset("tblHoliday", DB_OPEN_DYNASET)
Criteria = "HOLIDAY_DATE = #" & holdDate & "#"
Myset.FindFirst Criteria
If Myset.NoMatch Then 'Date is a working day
' write hold date to table
strDateDesc = Format$([holdDate], "dddd")
strholddate = Format$([holdDate], "mm/dd/yyyy")
Set Myset = MyDB.OpenRecordset("tblRptDates")
DoCmd.RunSQL "INSERT INTO tblRptDates(INDIVIDUAL_DATE,INDIVIDUAL_DAY,str_Individual_date) VALUES([holdDate],[strDateDesc],[strholddate]);"
holdDate = DateAdd("y", 1, [holdDate]) 'Add one day to holddate
intReportDays = intReportDays + 1 'Add one to counter
Else
holdDate = DateAdd("y", 1, holdDate) 'Add one day to holddate
End If
End If
Loop
Do While intReportDays < 7
'is hold date a weekend day
If (DatePart("w", [holdDate]) = 1) Then
holdDate = DateAdd("y", 1, holdDate) 'Add one day to holddate
Else 'is hold date a holiday
Set Myset = MyDB.OpenRecordset("tblHoliday", DB_OPEN_DYNASET)
Criteria = "HOLIDAY_DATE = #" & holdDate & "#"
Myset.FindFirst Criteria
If Myset.NoMatch Then 'Date is a working day
' write hold date to table
strDateDesc = Format$([holdDate], "dddd")
strholddate = Format$([holdDate], "mm/dd/yyyy")
Set Myset = MyDB.OpenRecordset("tblRptDates")
DoCmd.RunSQL "INSERT INTO tblRptDates(INDIVIDUAL_DATE,INDIVIDUAL_DAY,str_Individual_date) VALUES([holdDate],[strDateDesc],[strholddate]);"
holdDate = DateAdd("y", 1, [holdDate]) 'Add one day to holddate
intReportDays = intReportDays + 1 'Add one to counter
Else
holdDate = DateAdd("y", 1, holdDate) 'Add one day to holddate
End If
End If
Loop