Access Closing When Button is Clicked (1 Viewer)

tmyers

Well-known member
Local time
Today, 16:21
Joined
Sep 8, 2020
Messages
1,091
I am confused as to what is happening as I have several buttons that worked fine for months. Now all of a sudden, when you click several of them, Access stalls out for 5-10 seconds then closes and restarts. The code is super simple, so I am unsure what could have happened to make them all of a sudden behave this way.

Here is the code behind the latest button to start doing it. Most of the buttons have this variation of code, but not all check permission level (I know that is likely an ugly way of handling it).

Code:
Private Sub OpenUsersBtn_Click()

    If Forms!LoginFrm!PermissionLvlTxtbx <> 3 Then
        
        MsgBox "You are not authorized to use this feature"
        Exit Sub
    
    Else
    
        DoCmd.OpenForm "UserFrm", acFormDS
        
    End If

End Sub

Any idea why this would cause Access to crash and restart?
 
sometimes an update happens and access hits a snag on it and crashes.
you could try repairing. but its still the same code. Have you protected all API calls with both 32 bit & 64 bit?
Code:
#If Win64 Then      'Public Declare PtrSafe Function
Private Declare PtrSafe Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As LongPtr
#Else
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
#End If

or
I found a few successes by repairing the db on a PC that doesn't crash. Then the bad pc can run it.
or
rebuild the db from scratch on the bad pc by:
make a new blank db
import ALL items from the old db,
repair all references.
This too has worked on some troublesome pc's.

but I had 1 pc would not work with the db, even after all possible fixes. It just didnt like whatever call got altered.
 
Smells of some type of corruption. Have you done a Compact & Repair lately? If not, remember to ALWAYS make a copy of the file BEFORE you go diddling in it. Also, you could try to decompile your code. Again, backup BEFORE attempting. Also, the link has a couple of sub-headers before it gets to the decompile option so you might need to scroll down just a little bit to find it.

 
I have not modified anything in several months as it was running smoothly. The last C&R I did was roughly a week ago, but I want to say this started before that. I did another compact and repair and the button in question started working again. I closed Access and restarted it and when clicked again it crashed.

I am with you Doc, I think corruption is afoot somewhere.
 
windows can run updates. We've had to roll some back.
 
The computer did have an update pushed I think around the time this started. Ill have to check into that but I did just decompile per Doc's suggestion and after several tries and restarts, it has not crashed again.
 

Users who are viewing this thread

Back
Top Bottom