Prevent display of blank query/form

G

Guest

i have a parameter query based on inputs from the user. A form based on this
query pops-up to display matched records. My question is, how can i prevent
the display of a blank query/form, that is, when no matching records are
found? Instead, I want that the program will inform the user through a MsgBox
that "No Records Found". thanks in advance.
 
A

Allen Browne

Cancel the Open event of the form it if has no records:

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
Cancel = True
MsgBox "No Records Found"
End If
End Sub
 

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