Hello Forum!
I am trying to create an error handling for a split database at my work.
As you know, Access has a bug since the December update. When a second user logs in, it fails.
When starting the database, a hidden form is started that allows to register a username and date/time in the tblUserlog. When the backend is already locked, the username and date/time cannot be written to the tblUserlog. To deal with the resulting error message, I want to show the user a message that the database is already in use and then close it. I have created the following procedure for this purpose.
It works, but after closing the database, the message is displayed again. I don't understand what I'm doing wrong. Can someone help me with this?
Thanks for reading!
Kind regards, Bert
I am trying to create an error handling for a split database at my work.
As you know, Access has a bug since the December update. When a second user logs in, it fails.
When starting the database, a hidden form is started that allows to register a username and date/time in the tblUserlog. When the backend is already locked, the username and date/time cannot be written to the tblUserlog. To deal with the resulting error message, I want to show the user a message that the database is already in use and then close it. I have created the following procedure for this purpose.
Code:
Function LogOn()
On Error GoTo err_ErrorhandlerLogOn
Dim sUser As String
Dim sSQL As String
DoCmd.SetWarnings False
sUser = Environ("username")
sSQL = "INSERT INTO tblUserLog ( UserID )" _
& "SELECT '" & sUser & "' AS [User];"
DoCmd.RunSQL sSQL
DoCmd.SetWarnings True
Exit_MAA:
Exit Function
err_ErrorhandlerLogOn:
MsgBox "Unfortunately you cannot log in now. The database backend is already in use by another user or it is blocked for use." & vbCrLf _
& "" & vbCrLf _
& "Please try again later. The database will be shut down." & vbCrLf _
& "", vbOKOnly Or vbCritical, "Beste gebruiker ..."
Call DatabaseClose
Resume Exit_MAA
End Function
Code:
Private sub DatabaseClose()
Application.Quit acQuitSaveNone
End sub
It works, but after closing the database, the message is displayed again. I don't understand what I'm doing wrong. Can someone help me with this?
Thanks for reading!
Kind regards, Bert