Messagebox

J

JOM

I have a textbox that one will enter a number to search. The output if the
number exists is a report but if the number does not exist, I would like the
messagebox to indicate the number the user entered that it does not exist.

he is what my messagebox currently has:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The acctount number entered is not in the database",
vbInformation, "No such Accout number"
Cancel = True
End Sub
 
K

Ken Snell \(MVP\)

Try this (replace generic names of form and textbox):

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The acctount number entered " & _
Forms!NameOfYourForm!NameOfYourTextbox & _
" is not in the database", vbInformation, _
"No such Accout number"
Cancel = True
End Sub
 
L

Lance

IF DCOUNT("Account_Number","Account_Table","Account_Number = 123456") > 0
then
'DO WHATEVER AND RUN REPORT
ELSE
'ISSUE WARNING AND DON'T RUN REPORT
END IF
 
F

fredg

I have a textbox that one will enter a number to search. The output if the
number exists is a report but if the number does not exist, I would like the
messagebox to indicate the number the user entered that it does not exist.

he is what my messagebox currently has:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The acctount number entered is not in the database",
vbInformation, "No such Accout number"
Cancel = True
End Sub

Where are you entering the number to search for?
On a form?

MsgBox "The acctount number entered (" & Forms!FormName!ControlName &
") is not in the database", vbInformation, "No such Accout number"
 
J

JOM

What if the reports source is comming from a query whereby the ACTN2 criteria
I have the question enter number?
 
J

JOM

the report's record source is from a query and here is the query syntax:
SELECT tblMod.ACTN2, tblMod.OPEN_DATE, tblMod.MOD_TYPE, tblMod.START_DT
FROM tblMod
WHERE (((tblMod.ACTN2)=[Enter the account number]));
 
F

fredg

the report's record source is from a query and here is the query syntax:
SELECT tblMod.ACTN2, tblMod.OPEN_DATE, tblMod.MOD_TYPE, tblMod.START_DT
FROM tblMod
WHERE (((tblMod.ACTN2)=[Enter the account number]));

fredg said:
Where are you entering the number to search for?
On a form?

MsgBox "The acctount number entered (" & Forms!FormName!ControlName &
") is not in the database", vbInformation, "No such Accout number"

Your original message aid you were using a text box.
Text boxes are on forms or reports, not in queries.

Don't use the query prompt. Create a form to enter the value in.
As long as the form is open when the report is run you will get the
message if the report has no data. You will not get the value if you
use a parameter prompt.
Change the query criteria to:
WHERE (((tblMod.ACTN2)=forms!FormName!ControlName));
 
Top