How reports open queries

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

Guest

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
 
A report that has a query as the source will take care of running the query.
It won't open it per se. A query doesn't have to be viewed for it to run.
The sequence of events should be to select the beginning and ending date on
aform and then open the report either with a button on the form or using teh
After Update event of the end date control. You won't open the report then
have a form popup to select the dates as it is a waste of resources because
you would have to do a requery for the report to display the selected records.
 
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.
 
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
 
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]
 

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