I have following lines in VBA Access, but I receive Syntax Error by FindFirst and I don't understand why.
criteria = "[HolidayDate] = " & "#" & myDate & "#"
rst.FindFirst (criteria)
If rst.NoMatch Then
count = count + 1
End If
I have following lines in VBA Access, but I receive Syntax Error by FindFirst and I don't understand why.
criteria = "[HolidayDate] = " & "#" & myDate & "#"
rst.FindFirst (criteria)
If rst.NoMatch Then
count = count + 1
End If
Do While mydate <= EndOfMonth
If Weekday(mydate, vbMonday) < 6 Then
With rst
.MoveFirst
flag = False
Do While Not .EOF
If CDate(.Fields("HolidayDate").Value) = myDate Then
flag = True
End If
.MoveNext
Loop
If flag = False Then
count = count + 1
End If
End With
End If
myDate = myDate + 1
Loop
Looping through a recordset is not the solution.
If HolidayDate really is of data type DateTime, this will work:
criteria = "[HolidayDate] = #" & Format(myDate, "yyyy\/mm\/dd") & "#"
rst.FindFirst criteria
If not, something else is going on.