Messagebox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
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"
 
What if the reports source is comming from a query whereby the ACTN2 criteria
I have the question enter number?
 
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]));
 
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));
 

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

Back
Top