Consulting

Results 1 to 5 of 5

Thread: Macro Button Crashes Access

  1. #1
    VBAX Newbie
    Joined
    Jun 2017
    Posts
    3
    Location

    Macro Button Crashes Access

    Hi,
    I have a macro that runs when a button is clicked, this works fine initially. Eventually, over time (days/weeks), something goes wrong and it then causes the Access application to present the dialog box saying that it has stopped responding. I have this on a works networked PC and wonder if that can be the problem. I can fix it by opening the macro and resaving it (no changes required). This works on my version but not on other PC's often. Could this possibly be caused by O.S updates or overwriting the database with design changed version. The design changes not related to this button. I guess it is linked to some sort of verification step which maybe disrupted by something. Your help appreciated as it is becoming a pain to rectify.

    Thanks
    gadget01

    my button code:

    Private Sub Command87_Click()
    strInput = InputBox("Please note:" & vbCrLf & "Using other than the green Data Entry buttons on this menu page to edit should not be done if your edit requires progressing the waste through one of the waste diposal steps" & vbCrLf & vbCrLf & "If you really must edit a waste item then beware of your actions.... " & vbCrLf & vbCrLf & "Enter Password:")
    
    If strInput = "****" Then
    DoCmd.OpenForm "Admin Menu"
    Else: MsgBox ("Sorry, you do not have access privilege!"): Exit Sub
    End If
    End Sub
    Last edited by SamT; 06-26-2017 at 10:05 AM.

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    I would suggest that the first thing you need is to add some Error Trapping and reporting VBA to your Macro to establish if it is something in the code causing it or it is an external issue.

    I weould change your code to this

    Private Sub Command87_Click()
    On Error GoTo Eventerror
    
    strInput = InputBox("Please note:" & vbCrLf & "Using other than  the green Data Entry buttons on this menu page to edit should not be  done if your edit requires progressing the waste through one of the  waste diposal steps" & vbCrLf & vbCrLf & "If you really must  edit a waste item then beware of your actions.... " & vbCrLf &  vbCrLf & "Enter Password:")
    
    If strInput = "****" Then
    DoCmd.OpenForm "Admin Menu"
    Else: MsgBox ("Sorry, you do not have access privilege!"): Exit Sub
    End If
    Exit Sub
    
    Eventerror:
    MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
    
    'Use this and come back when the error occurs again with any message that it may develop.
    End Sub
    I also notice that the strInput you are using is not dimensioned, I am not sure if that would have an effect or not.
    Last edited by SamT; 06-26-2017 at 10:06 AM.

  3. #3
    VBAX Newbie
    Joined
    Jun 2017
    Posts
    3
    Location
    Thanks for your reply, both good points, I will try the following. So far no errors.
    Private Sub Command87_Click()
    Dim strInput As String
    On Error GoTo Eventerror
    
    strInput = InputBox("Please note:" & vbCrLf & "Using other than the green Data Entry buttons on this menu page to edit should not be done if your edit requires progressing the waste through one of the waste diposal steps" & vbCrLf & vbCrLf & "If you really must edit a waste item then beware of your actions.... " & vbCrLf & vbCrLf & "Enter Password:")
    
    If strInput = "****" Then
        DoCmd.OpenForm "Admin Menu"
    Else: MsgBox ("Sorry, you do not have access privilege!"): Exit Sub
    End If
    
    Eventerror:
     MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
    End Sub
    Last edited by SamT; 06-26-2017 at 10:07 AM.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Gentlemen. If you select all your code, then click the # icon in the Post Editor menu, it will place Code Formatting Tags around your code, so that it looks like the above three messages.

    Note that I also added some white space above to break your codes into logical segments.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Newbie
    Joined
    Jun 2017
    Posts
    3
    Location
    Quote Originally Posted by SamT View Post
    Gentlemen. If you select all your code, then click the # icon in the Post Editor menu, it will place Code Formatting Tags around your code, so that it looks like the above three messages.

    Note that I also added some white space above to break your codes into logical segments.

    I didn't know that thanks, it looks much better. I'll give it a try.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •