Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter form

Status
Not open for further replies.

Hillbillie

IS-IT--Management
Jun 28, 2005
23
US
I am currently using a command button to filter certain records to the form. For example. I have one button called "A" that filters all lastnames that are like "A"
I have buttons A thru Z and an ALL button

These work great, unless there is no Lastnames like A, then it opens the form in a blank form. I want it to popup a msgbox, telling me there are no records, and then after I press ok, it will go end and go back to where it was.

Current Script:

Private Sub Abutton_Click()
Me.Filter = "Lastname like 'A*'"
Me.FilterOn = True
End Sub

Thanks

 
could you use something like:
If DCount("Lastname","table or query that is recordsource", "Lastname like 'A*'") > 0 then
Me.Filter="Lastname like 'A*'"
Me.FilterOn=True
Else
msgbox "no records"
End If
 
Thanks spizotfl, it worked like a champ.

Below is my final code.

If DCount("Lastname", "Donors", "Lastname like 'A*'") > 0 Then
Me.Filter = "Lastname like 'A*'"
Me.FilterOn = True
Else
MsgBox "There are no records with this lastname"
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top