Error Trap Help

G

Guest

Hello I have error 2450 when I try to close the app. I want to disreguard or
ignore this error. How is this done? I tried this code in the close button of
the app and its taking me to the VBA code at this line in the code (Resume
Exit_cmdPreview_Click) What am I missing in the code and where would it go in
the code to get this to work? Thanks!!!

VBA Code:

Err_cmdPreview_Click:
If Err.Number = 2450 Then ' ignore cancel event error
MsgBox Err.Number & " - " & Err.Description
Else
Resume Exit_cmdPreview_Click
End If
End Sub
 
G

Guest

The code you have is actually telling Access to do exactly the opposite of
what you want. If you want to ignore error 2450 then it should look
something more like this;

Err_cmdPreview_Click:
If Err.Number = 2450 Then
Resume Next
Else
MsgBox Err.Number & " - " & Err.Description
Resume Exit_cmdPreview_Click
End If
End Sub

This states that if the error number is 2450 then resume at the next line
after the If statement (which is End Sub), otherwise display a message box.

HTH
 
G

Guest

Beetle, I am getting a debug in the VBA line (Resume Exit_cmdPreview_Click)
This is the close button for my database here is the code I have in there
before adding the error trap aparently i doing something wrong. How would I
add the error trap in the code I have here now? Thanks!!

Private Sub imgCmdLogOff_Click()
'// Calls the Click.wav sound
API_PlaySound CurrentProject.Path & "\AccessSounds\Click.wav"

'//Exits application
DoCmd.Quit

End Sub
 
G

Guest

Copy an post all the code in your cmdPreview_Click event. If I can't help you
hopefully someone else in this group will have some suggestions, but we will
need to see the code first. I don't know specifically what error 2450 is, but
perhaps it is an error that shouldn't be ignored. If your debug keeps taking
you back to the Resume Exit_cmdPreview_Click line, then it seems like the
problem must be somewhere in your cmdPreview_Click routine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top