0

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
braX
  • 11,506
  • 5
  • 20
  • 33
Silvia
  • 9
  • 2

2 Answers2

0
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
Silvia
  • 9
  • 2
0

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.

Gustav
  • 53,498
  • 7
  • 29
  • 55