I get 2 message boxes - one custom one system

  • Thread starter Thread starter Dic_nutana
  • Start date Start date
D

Dic_nutana

Hi I have the following code which runs when I open a second form... it works
great but unfortunately I get a second system message box as well as my own
custom box what have I missed out?
can anyone help
many thanks in advance

:
Private Sub Form_Open(Cancel As Integer)

If Me.Recordset.RecordCount = 0 Then
Cancel = True
MsgBox "There are no records to display."

End If

End Sub
 
Hi Mark

sorry I should have put that

Message reads - "The Open Form Action was Canceled"

and it's access 2003 in 2000 file format
hope that helps
many thanks
regards Dic
 
Dic_nutana said:
Hi I have the following code which runs when I open a second form... it
works
great but unfortunately I get a second system message box as well as my
own
custom box what have I missed out?
can anyone help
many thanks in advance

:
Private Sub Form_Open(Cancel As Integer)

If Me.Recordset.RecordCount = 0 Then
Cancel = True
MsgBox "There are no records to display."

End If

End Sub


If you're getting error 2501, "The OpenForm action was cancelled" (or
something like that), it's probably because you are opening the form in
code, and your code here is cancelling the open. That results in the error
being raised in the code that performs the open. You must add
error-handling to that code, trap error 2501, and ignore it.
 
Thanks Dirk thats did the job

many thanks

Dirk Goldgar said:
If you're getting error 2501, "The OpenForm action was cancelled" (or
something like that), it's probably because you are opening the form in
code, and your code here is cancelling the open. That results in the error
being raised in the code that performs the open. You must add
error-handling to that code, trap error 2501, and ignore it.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top