Opening a report with out using criteria.

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

Guest

I want the user to be able to open up a report that can only be printed with
information from a form. When I open the report I get the box that want the
record ID. I am assuming on the cmd button I have to add some sore of
criteria to get rid of the error. How do I do that?

Also, when the report is opened it displays errors because there is no
record to get the information from. Is there a way to have the report show
nothing or something other than error?
 
Sounds like you have a parameter in the query that feeds the report (or
possibly in the report itself).

Remove the parameter. Instead use the WhereCondition of the OpenReport
action to apply the criteria based on the ID in the text box. If the text
box is null, then leave the WhereCondtion blank, and the report will show
all records.

There's an example of the kind of code you need in this link:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

The #Error shows in all the calculated controls on the report when there is
no data. It is possible to use IIf() with the HasData property of the report
to show a Null instead of the error if there is no data. However, the easier
solution is probably to cancel the NoData event of the report if there is no
data. This way the report never opens. You can show a MsgBox instead if you
wish. You will need to use error handling in the code that does the
OpenReport, and trap error 2501.
 
Back
Top