Error Message for REPORT if wrong number entered

K

kealaz

I have a report whose Record Source is a query.

The query pulls information from two tables based on information entered by
the user, using the following in the Criteria.

Like [Enter Drawing Number:] & "*"


Right now, if an incorrect number is entered, I get a blank report. I would
like to have an error message appear if the number entered is not in the
drawing or part log.


Msgbox "Invalid part number. Please re-enter."


What code would I use, and where would I put it?


Thanks so much for your assistance!!!
 
D

Dirk Goldgar

kealaz said:
I have a report whose Record Source is a query.

The query pulls information from two tables based on information entered
by
the user, using the following in the Criteria.

Like [Enter Drawing Number:] & "*"


Right now, if an incorrect number is entered, I get a blank report. I
would
like to have an error message appear if the number entered is not in the
drawing or part log.


Msgbox "Invalid part number. Please re-enter."


What code would I use, and where would I put it?


You can use the report's NoData event to do this. You might have an event
procedure like this:

'----- start of code -----
Private Sub Report_NoData(Cancel As Integer)

Cancel = True

MsgBox _
"Report cancelled -- " & _
"there is no data for the drawing number you entered.", _
vbInformation, _
"Nothing to Report"

End Sub
'----- end of code -----
 

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