Solved Runtime error - 3073 (1 Viewer)

Ashfaque

Student
Local time
Tomorrow, 01:36
Joined
Sep 6, 2004
Messages
894
Hi,

I have below code line (from full code set) that producing Runtime error - "Operations Must Use An Updatable Query

Code:
 CurrentDb.Execute "UPDATE tblLoginSessions SET LogoutEvent = Now()" & _
            " WHERE UserName=GetUserName() AND LogoutEvent Is Null AND ComputerName=GetComputerName();"

The basic idea was to clear server tbl data of the user.

Any idea please?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:06
Joined
May 7, 2009
Messages
19,231
CurrentDb.Execute "UPDATE tblLoginSessions SET LogoutEvent = '" & Format(Now(), "yyyy-mm-dd hh:nn:ss") & ".000'" & _
" WHERE UserName= '" & GetUserName() & "' AND LogoutEvent Is Null AND ComputerName='" & GetComputerName() & "';" dbSeeChanges

Or, if LogoutEvent is Date type:

CurrentDb.Execute "UPDATE tblLoginSessions SET LogoutEvent = Now() " & _
" WHERE UserName= '" & GetUserName() & "' AND LogoutEvent Is Null AND ComputerName='" & GetComputerName() & "';", dbSeeChanges
 

Minty

AWF VIP
Local time
Today, 21:06
Joined
Jul 26, 2013
Messages
10,366
I think you would need to concatenate the functions results into that string.

Create a strSQL to assist you with debugging.

I can't seem to post the code due to a forum error!
 

Ashfaque

Student
Local time
Tomorrow, 01:36
Joined
Sep 6, 2004
Messages
894
Thanks Gentlemen,

I added PK to the table and it worked.

Thanks for your support..

Regards,
 

Users who are viewing this thread

Top Bottom