Hello,
I'm having an issue with a query that previously was working - not sure what I changed to make it not work anymore.
First, I have a module that creates a function "GetBusinessDay." This is the code for that module:
Here is the query. The field 30Day calculates 30 working days, with a where expression (>=Date())to narrow down the results to only those records equal to today or in the future.
I have started getting a Data Type Mismatch In Criteria Expression error for this where statement. I have tried everything I can think of, but from what I can tell the module should keep it as a date field but it is becoming text, so I am comparing text to date. I tried using a datevalue on the field but I still get the error. Tried using an If statement to change it to string, and still get an error. Help please!
Here is the query:
I'm having an issue with a query that previously was working - not sure what I changed to make it not work anymore.
First, I have a module that creates a function "GetBusinessDay." This is the code for that module:
Code:
Function GetBusinessDay(datStart As Date, intDayAdd As Integer)
On Error GoTo Error_Handler
Dim rst As DAO.Recordset
Dim DB As DAO.Database
Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [BMWHoliday] FROM tbl_Holidays", dbOpenSnapshot)
If intDayAdd > 0 Then
Do While intDayAdd > 0
datStart = datStart + 1
rst.FindFirst "[BMWHoliday] = #" & datStart & "#"
If Weekday(datStart) <> vbSunday And Weekday(datStart) <> vbSaturday Then
If rst.NoMatch Then intDayAdd = intDayAdd - 1
End If
Loop
ElseIf intDayAdd < 0 Then
Do While intDayAdd < 0
datStart = datStart + 1
rst.FindFirst "[BMWHoliday] = #" & datStart & "#"
If Weekday(datStart) <> vbSunday And Weekday(datStart) <> vbSaturday Then
If rst.NoMatch Then intDayAdd = intDayAdd + 1
End If
Loop
End If
GetBusinessDay = datStart
Exit_Here:
rst.Close
Set rst = Nothing
Set DB = Nothing
Exit Function
Error_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here
End Function
I have started getting a Data Type Mismatch In Criteria Expression error for this where statement. I have tried everything I can think of, but from what I can tell the module should keep it as a date field but it is becoming text, so I am comparing text to date. I tried using a datevalue on the field but I still get the error. Tried using an If statement to change it to string, and still get an error. Help please!
Here is the query:
Code:
SELECT qry_EmployeeDbList.EmployeeName, qry_EmployeeDbList.HireDate, GetBusinessDay([HireDate],30) AS 30Day, qry_EmployeeDbList.Position
FROM qry_EmployeeDbList
WHERE (((GetBusinessDay([HireDate],30))>=Date()) AND ((qry_EmployeeDbList.Position)<>"Floater"));