report and opening and message

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

Guest

When executing a report If the underlying query for a report has no records,
how can i display a message box with a critical error statement, rather than
try to open a dud report
 
sorry to bug you on one more thing..

can you tell me how to suppres msaccess error messages when there is an
error in the query (data type mis match), i want my own error message , or
none at all.

have tried set warnings off
and docmd setwarnings false

neither work
 
this is whilke opening the report. sometimes the underlying query will come
up with that error and i want to suppress it.
 
The issue you are describing now is completely different than your first one.
If you are receiving error messages in the query than my guess would be
this is a form issue. Presumably you are passing information from a form
to the query that feeds the report. What you need to do is set up some data
validation on the form before launching the report (and subsequent query).

So, for example, you need to have a date in a control on the form that
will be passed to the report query. If the user enters some text or other
strange characters the query will of course have issues with this. So
behind the command button that launches the report, first do some checking
on the information the user has entered. You could test to see if it actually
is a date (or can be interpreted as one), you could see if the date falls within
a certain range, whether it is a future date, etc. You could (and should)
even check to see of the user actually entered anything as well.

Once all of your data validations pass the tests, then you open the report.
Since the report's query recordsource *should* be happy now, you will
not receive that error message. You can still use the report's OnNoData
event to close the report if no records were returned.

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
Back
Top