Escape Key Problem

philljp390

Registered User.
Local time
Today, 16:16
Joined
Sep 7, 2003
Messages
64
I have a button on a form, when clicked opens another form based on a query.

If you press the Escape Key while this query is running it comes up with:

"Run-Time error '2501'"

The OpenForm action was canceled.


Debug takes me to:

DoCmd.OpenForm "frmInfoPull", acNormal

So I need something that if someone presses the Escape Key, while this query is running, it simply stops the query.

:confused:
 
in the error handler

Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
If Err = 2501 Then
Resume Exit_Command5_Click
Else
MsgBox Err.Description
End If
Resume Exit_Command5_Click
change Command5 with your own button name
 
sorry for being stupid, but wheres the "Error Handler" :o
 
the code for your button should look something like

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
DoCmd.OpenForm "frmInfoPull", acNormal
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
If Err = 2501 Then
Resume Exit_Command5_Click
Else
MsgBox Err.Description
End If
Resume Exit_Command5_Click


End Sub

you need to replace all references to Command5 with your own button name
 

Users who are viewing this thread

Back
Top Bottom