Login and User Access (1 Viewer)

isladogs

CID Moderator
Staff member
Joined
Jan 14, 2017
Messages
12,306
Hi Colin.....not sure you got my message but i can't seem to get the LogOut code from the Log me Out button on frmSessions to work with my Quit Button on my switchboard. I added the code and then added a DoCmd.Quit directly after it but it gives me a Data Member Not Found error. I tried adding a reference to the form frmSessions to the code but it didn't work ?

I changed Me.1stSessions.Requery to

Forms![frmSessions]!1stSessions.Requery
Sorry - only just noticed this. Drowning in emails today....

I'm a little confused here.
First of all, did you use/adapt the entire code behind that button?

Is frmSessions open? If not you would get an error
If you are about to quit and don't actually have frmSessions open at the time, just omit the Requery line. Its not needed unless you are viewing the form (or if you are about to quit!)

Follow that logoff code with Application.Quit (which is preferable to DoCmd.Quit)
You may need to add a DoEvents line first to ensure the logoff does occur before the app quits.

If that doesn't help, perhaps it would be easier for me to follow if you can upload the relevant parts of your database. Remove any confidential data and all irrelevant objects
 

Emma35

Registered User
Joined
Sep 18, 2012
Messages
271
This was the very last thing i had to do !. Everything else is fine. I've removed the Requery line and added a line to shut the database but nothing happens when i press the button ?. Here's the code i have

Code:
Private Sub cmdLogout_Click()

On Error GoTo Err_Handler

' Close the session for this user and flag them as logged out.
    Call CloseSession
    Call LogMeOff(lngLoginID)

Exit_Handler:
    Exit Sub

Err_Handler:
    MsgBox "Error " & Err.Number & " in cmdLogout_Click procedure: " & Err.Description
    Resume Exit_Handler
    
    Application.Quit
    
End Sub
 

Gasman

Enthusiastic Amateur
Joined
Sep 21, 2011
Messages
5,013
You are never going to Quit even if you have an error? :confused:

Try
Code:
    Call CloseSession
    Call LogMeOff(lngLoginID)
    DoEvents
    Application.Quit
 

isladogs

CID Moderator
Staff member
Joined
Jan 14, 2017
Messages
12,306
Gasman
Thanks for stepping in to assist.

Emma
As Gasman stated, in the code you posted, the Quit line would never have been reached whether or not you had an error.

Glad to see you now have working code
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom