Error Message for REPORT if wrong number entered

  • Thread starter Thread starter kealaz
  • Start date Start date
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!!!
 
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 -----
 
Back
Top