Error trapping shows 2 times message for user (1 Viewer)


New member
Local time
Today, 07:40
Jan 22, 2022
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.

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 Function

    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

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


Immoderate Moderator
Staff member
Local time
Today, 00:40
Feb 28, 2001
You are saying that you see the message from your MsgBox call twice? If I understand the way error traps work, the only way that can occur is if you get to your label err_ErrorhandlerLogin twice through two traps. A trap cannot trap itself (because at the time of the trap, the trap handler is active and Access has a way of knowing that.) It has to leave that handler through a Resume statement before the trap would reset.

The ONLY thing I would do differently there is that the Call DatabaseClose MAYBE shouldn't be inside an error handler but rather you should Resume to a label that THEN calls your DatabaseClose code before exiting the function. But I am not certain about the implied fine point of calling code subroutines from event handler context causing a repeat of a message box.

I tried a couple of searches on the topic, but so far nothing jumps out at me. On the other hand, that behavior of "exclusive use" has been seen recently due to a Windows patch-related bug and there are some articles here on how to fix that problem. Try this link....



Grover Park George
Local time
Yesterday, 22:40
Nov 25, 2004
Depending on which version of Access you have, the fix may already be available. IIRC, three versions are listed as having the fix pending. Check the link in post #2 for details. That's the most current and comprehensive summary available.


Registered User.
Local time
Today, 15:40
Jul 4, 2013
As you know, Access has a bug since the December update. When a second user logs in, it fails.
Not exactly. Microsoft released a server security patch which had the unintended affect on Access databases of allowing only one user read/write. A fix was released on January 14.

Rather than proceeding with your alert, have IT implement the fix. Note that to be effective, you need to change any links to data from mapped drives to UNC references.

Users who are viewing this thread

Top Bottom