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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox when filter doesn't find data 1

Status
Not open for further replies.
Oct 24, 2002
512
US
I have a form that allows the user to enter a filter into a text box. (i.e., open frmEmployeeData where ContractNumber = some text value the user enters)

It works fine if I have employees assigned to that contract number. But, if no employees are assigned to that contract number my form opens with no data fields. I'd like to display a message saying there are currently no records that match the user's criteria but can't figure it out. I know I could use the NoData event on a report but what about a form?

Ann
 
Hi,

You could do a DCount on the Table/Query your Form is bound to:
Dim x As Long
x = DCount("*", "[tbl/qryEmployeeData ]", "[ContractNumber] = " & variable that stores some text value the user enters
If x > 0 Then
'perform the filter
Else
MsgBox "There are no Records matching your request"
End If

Bill
 
Thanks, Bill. This is exactly what I needed. It works like a charm.

Ann
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top