WHERE clause with a Max(Date) functionality in VBA, SQL Back-end, Access front-end

StackOverflow https://stackoverflow.com//questions/20055114

  •  02-01-2020
  •  | 
  •  

Frage

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

War es hilfreich?

Lösung

The most obvious correction:

strSQL1 = "Update tTbl_LoginSessions SET fldLogoutEvent = '" & _
           Now() & "'" & " WHERE fldUserName = " & IntMSIDAutoNum  & _
           " And fldLoginEvent =  (select top 1 fldLoginEvent from " & _
           " tTbl_LoginSessions )"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top