WHERE clause with a Max(Date) functionality in VBA, SQL Back-end, Access front-end
-
02-01-2020 - |
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
La solution
The most obvious correction:
strSQL1 = "Update tTbl_LoginSessions SET fldLogoutEvent = '" & _
Now() & "'" & " WHERE fldUserName = " & IntMSIDAutoNum & _
" And fldLoginEvent = (select top 1 fldLoginEvent from " & _
" tTbl_LoginSessions )"
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow