Error Handling using Case - SOLVED

StuLux

Well-known Member
Joined
Sep 14, 2005
Messages
662
Office Version
  1. 365
Platform
  1. Windows
The following code is producing error 2501 at the line indicated, the code was working fine and I had previoulsy added error handling to effectively ignore this error but the error handler no longer picks up this error - can anybody explain why?

I have additional code in the Form_BeforeUpdate event but this merely runs through the controls on the form and produces msgbox prompts if any of the entries do not compy with certain rules. I'm not aware of making any chnages to this code from when it was working OK so I'm at a complete loss.

Code:
Private Sub cmdClosefrmProjects_Click()
On Error GoTo Err_cmdClosefrmProjects_Click

    Call Audit

    If Me.Dirty Then
        DoCmd.RunCommand acCmdSaveRecord 'ERROR OCCURS HERE
    End If
    DoCmd.Close acForm, Me.Name

Exit_cmdClosefrmProjects_Click:
    Exit Sub

Err_cmdClosefrmProjects_Click:
    
    Select Case Err.Number
        Case 2501 'Ignores the "run command action was cancelled" error
        Case Else
            msgbox "Error " & Err.Number & ": " & Err.Description, vbCritical, "modName.FunctionName"
    End Select
    
    Resume Exit_cmdClosefrmProjects_Click
    
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
What is error 2501? I don't have all, or any, of the numbers memorized.
 

StuLux

Well-known Member
Joined
Sep 14, 2005
Messages
662
Office Version
  1. 365
Platform
  1. Windows
I found the problem was that I had set the General Options in VBA to "Break on all errors" without realising what this actually did - doh.
 

Forum statistics

Threads
1,181,722
Messages
5,931,673
Members
436,798
Latest member
spprtpplcm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top