Create error messages

Kila

Registered User.
Local time
Today, 05:28
Joined
Mar 5, 2003
Messages
275
I have a very simple database I wrote a few years ago that provides reports on data (mainly calculating sums & percents on those sums). When run, the reports open form-dialog boxes that prompt for criteria. The dialog boxes then become invisible & the query accesses the data in the invisible form & allows the report to run.

What is the easiest way to have the program display error messages when
1. The criteria entered is not found
2. The form/dialog box has an empty field

Right now, the computer has an automatically-generated action failed message and the macro halts. These are confusing to the user.

Thanks for any suggestions!
 
You can use the

'----ADD TO BEGINING OF SUB----
On Error GoTo On_Error_Action2
'form element null
If IsNull(frmText1) Or frmText = "" Then
On_Error_Action1
End If


'---BEFORE END OF SUB--------
Exit_Now:
Exit Sub

On_Error_Action1:
MsgBox "In Sufficient Elements On Form Yo"
Resume Exit_Now
On_Error_Action2:
MsgBox err.Description
Resume Exit_Now
 
Thanks

Thank you. I will try this. What about if the criteria entered is not found?
 
If its in a database table you could use VLOOKUP

Dim varX Variant

varX = DLOOKUP("FIELD", "TABLE", "FIELD = '" & frmText1 & "'")

if isNull(varX) then
msgbox("what you thinking yo")
exit_sub
end if
 
Use DLOOKUP if its in a table

Dim varX as Variant

varX = DLOOKUP("Field", "Table", "Field = '" & frmText1 & "'")

if isnull(varX) then
msgbox("what you thinking yo")
Exit Sub
end if
 
Ok...

I'm a bit new to programming commands. Please bear with me!

The criteria is being entered into a form (pops up like a dialog box). A query is run that is based on what is entered in the form. I am looking for an error I can use if the query fails to find the criteria entered on the form. Can I still use what you posted?
 

Users who are viewing this thread

Back
Top Bottom