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

MsgBox if NoData found

Status
Not open for further replies.

mauricionava

Programmer
Jul 8, 2005
209
US
Hello guys, how can I set a message in a form that runs a query in the back that, if there is no data found, display a message saying that there was no data found?

I have a query that looks up fields in a table and does some calculations and if there is no data found it freezes and does not show anything, no fields, no lables, etc.

I want a msgbox to display a message when there is no data found.
Thanks!
 
You can do this, but the code used depends on how you are getting the data from the query.

Could you post an example of your code to show us how you are retrieving the data?

Cheers

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Sure,
the query looks for ACCT, LAST, FIRST, STATUS, INTEREST, and calculations in the TOTAL.
The criteria in ACCT is [ENTER ACCT NUMBER] and [ENTER INTEREST AMOUNT] for INTEREST.

 
Try this

Private Sub Command0_Click()
Dim msg As String
If IsNull(DLookup("FieldName", "QueryName")) Then
msg = "No data. "
MsgBox msg
End If
End Sub
 
Where should I put that code?
I have a switchboard with a button that when I click on it, it automatically asks for the criterias and then it shows the form with the data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top