In Access 2002, I have the following code to search a table and return a true/false result if the date 'dtedate' appears in the table.
It keeps returnig an error "Object vairiable or With Block variable not set"
Public Function IsAHoliday(ByVal dteDate As Date) As Boolean
Dim db As DAO.Database
Dim rsHoliday As DAO.Recordset
Set db = CurrentDb()
Set rsHoliday = db.OpenRecordset("SELECT holidayDate From tbl_PublicHolidays WHERE HolidayDate = #'" & dteDate & "'#;"
IsAHoliday = False
MsgBox (dteDate)
With rsHoliday
If .EOF Then
Exit Function
Else
IsAHoliday = True
End If
End With
rsHoliday.Close
Set rsHoliday = Nothing
End Function
Can anybody help!
It keeps returnig an error "Object vairiable or With Block variable not set"
Public Function IsAHoliday(ByVal dteDate As Date) As Boolean
Dim db As DAO.Database
Dim rsHoliday As DAO.Recordset
Set db = CurrentDb()
Set rsHoliday = db.OpenRecordset("SELECT holidayDate From tbl_PublicHolidays WHERE HolidayDate = #'" & dteDate & "'#;"
IsAHoliday = False
MsgBox (dteDate)
With rsHoliday
If .EOF Then
Exit Function
Else
IsAHoliday = True
End If
End With
rsHoliday.Close
Set rsHoliday = Nothing
End Function
Can anybody help!