Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cancel pop up

Status
Not open for further replies.

tizwaz

Technical User
Aug 8, 2002
437
GB
I have code on the onopen event of my form so that if there are no records it gives a message and cancels the open form event. How can I stop it giving me the system message saying the opoen form event was cancelled after my own message?
 
instead of canceling the event try
Code:
docmd.Close acForm ,me.name
 
It is quite common to trap such an error.

Code:
On Error GoTo TrapErr
DoCmd.OpenForm "frmForm"

ExitHere:
Exit Sub

TrapErr:
If Err.Number = 2501 Then
    'Event cancelled
    Err.Clear
    Resume ExitHere
Else
    'Error
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top