No Records In form

B

brian

If I open a form and there are No records to be dispayed how can I have a message box pop up to notify the user there are no records instead of having a blank form screen pop up. I am passing paramaters from one form to another if that matters. The receiving form is the one I am seeking to determine if there are blank records.

Thanks
 
B

Bruce M. Thompson

If I open a form and there are No records to be dispayed how can I have a
message box pop up to notify the user there are no records instead of having a
blank form screen pop up. I am passing paramaters from one form to another if
that matters. The receiving form is the one I am seeking to determine if there
are blank records.

The following code, placed in the called form's "On Open" event procedure,
should work for this:

'*********
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "The form returned no records."
Cancel = True
End If
'*********

In the above code, if the form's recordset returns no records, the message box
notifies the user and the form does not finish opening. You will need to trap
for Error 2501 in the calling code or you will get an error message whenever the
form's "Open" event is cancelled.
 

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