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.