Type mismatch error on DMax function using dates

Pis7ftw

Registered User.
Local time
Today, 10:30
Joined
Aug 5, 2012
Messages
37
Been awhile since I've asked a question! (Must mean I'm getting OK at this whole VBA programming thing ;) )

Anyway I've got a type mismatch that I can't figure out.
Code:
 dMaxLstReq = DMax("reqNumb", "FlightLog", "Month([txtDate])='" & frmMonth & "'" And "Year([txtDate])='" & frmYear & "'")

In plain english: Select the highest value in the field named reqNumb from FlightLog where the Month of txtDate is equal to the variable frmMonth and the year of txtDate is equal to the variable frmYear.

txtDate is a Date/Time field in the table FlightLog

frmMonth and frmYear are both integer variables that take the system time (sysTime) and determine the month and year: I.E.

Code:
frmMonth = Month(sysTime) & frmYear = Year(sysTime)

Am I correct in thinking that the fact that my variables are integers and not times, that this is the cause of the mismatch?

How would one go about fixing this?
 
You are correct... and wrong :P

I believe the way it should work is ...
dMaxLstReq = DMax("reqNumb", "FlightLog", "Month([txtDate])=" & frmMonth & " And Year([txtDate])=" & frmYear & "")

For sure remove the ' but with my tired and hurting brain not sure about the And part .... and cba testing it (sorry)
 
Thank you sir!
 

Users who are viewing this thread

Back
Top Bottom