Filters that find no records

N

Nick.Korynski

I am using the openform command to open a form based on user data that
is inputted. It works great when the data entered matches something in
my table, but when no data exists a pop up box appears asking for the
user to enter data. Is there anyway to detect when no records are
returned so that I can display a message box or something letting the
user know that no records were found? Thanks.

Nick
 
N

Nick.Korynski

Works great. Thanks!
You could do a DLookup to see if the data exists before opening the form.
Since I don't know your form, table, or field names, this will be an example
you will have to change the names in to make it work for you:

If IsNull(DLookup("[CustID]", "tblCustomer", "[CustID] = " &
Me.txtCustID)) Then
MsgBox Me.txtCustID & " Not Found"
Else
Docmd.OpenForm "frmCustomer", , , "[CustID] = " & Me.txtCustID
End If

--
Dave Hargis, Microsoft Access MVP


I am using the openform command to open a form based on user data that
is inputted. It works great when the data entered matches something in
my table, but when no data exists a pop up box appears asking for the
user to enter data. Is there anyway to detect when no records are
returned so that I can display a message box or something letting the
user know that no records were found? Thanks.

Nick
 
Top