Question

Within Access, I am trying to build a WHERE clause with a Max(Date) functionality, but it is not working. Any help would be greatly appreciated.

strSQL1 = "Update tTbl_LoginSessions SET fldLogoutEvent = '" & Now() & "'" & _
 " WHERE fldUserName = " & IntMSIDAutoNum And fldLoginEvent = MAX(fldLoginEvent)

fldLoginEvent is the date/time in which the User Logged in fldLogoutEvenr is the date/time in which the User will be logged out

Was it helpful?

Solution

The most obvious correction:

strSQL1 = "Update tTbl_LoginSessions SET fldLogoutEvent = '" & _
           Now() & "'" & " WHERE fldUserName = " & IntMSIDAutoNum  & _
           " And fldLoginEvent =  (select top 1 fldLoginEvent from " & _
           " tTbl_LoginSessions )"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top