I get 2 message boxes - one custom one system

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
 
D

Dic_nutana

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
 
D

Dirk Goldgar

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.
 
D

Dic_nutana

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)
 

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