How reports open queries

R

richard

I have a problem, my boss is not prepared to enter start and end dates for a
report, instead he wants to enter the data using a pop-up calendar. I have
created the form for the calendar and have managed to get the form to open
the query required for the report, however I need to have the report open the
form first rather than the query, however I cannot see an event within the
report which opens the query. Can someone tell me where this is if it exists
and if it doesn't exist how I can get the report to open the form before the
query.

Thanks

Richard
 
J

Jerry Whittle

A report really doesn't have an event that can open up a form first. I guess
you could try something on the On Open event, but that's still putting the
cart before the horse.

The query used as the Control Source of a report runs automatically when the
report is opened.

Have a button on a startup or Switchboard form open up your calendar form
first. After entering the dates, have a button that runs the report.
 
R

richard

Thanks to both of you for replying. I have just had a curry and watched a bit
of telly, and had come to my study to work on the database having come to the
conclusion that the best way was to open the form first from the switchboard,
and using code open the report with the form still open which would trigger
the query and hey presto I get everything I want. Your replies have confirmed
that this is the best way to do this.

Many thanks

Richard
 
J

John W. Vinson

A report really doesn't have an event that can open up a form first. I guess
you could try something on the On Open event, but that's still putting the
cart before the horse.

Actually, the Open event can be used for just this purpose. You can open an
unbound Form in the open event, in dialog mode, and use controls on that very
form as criteria for the Report's query. The code in the Open event will stop
executing when the form opens; you would put a command button on the form
which resumes the report's execution by setting the form's Visible property to
False. You should also put code in the report's Close event to close the form.

John W. Vinson [MVP]
 
Top