Getting the OnOpen Event of a Report to Open A Form

G

Guest

Hi, This is a continuation of my previous post on 6/9/2005 "Questions on
Control boxes, Parameter queries and calendars in reports."
As background, I am using Access 2003 on a PC with WIN XP Professional. I
have a report based on a three parameter query with the 3 parameters being 1)
Agency, 2) Beginning Date, and 3) Endng Date. My report works fine but I
wanted something besides just a "parameter" box opening and asking for data.
In fact, I do not even know how to tell the user what data to input. As an
example, when they are prompted for Agency, do they input COE, Corp of
Engineers, or what? When prompted for a date, do they input May 31, 2005,
5/31/05, or what? What if the user inputs the ending date as the beginning
date and vicew versa. How can I tell the user the end date needs to occur
after the beginnign date? So, now that I have created a calendar form
(frmCalendar), how do I get this form to open in the Reports OnOpen event?
How do I get the date selected on the calendar to be the date accepted by the
parameter query? How can I get the user to know what data and the correct
format to enter? I have created a macro that the OnOpen event calls but it
opens the form at the same time as the Agency parameter box pops up, which is
not what I want. The order of what parameter pops up 1st does nto matter as
long as each parameter is entered. Thanks in advance. As always, I am ready
to provide additional info.
Andy

Why not develop a dialog form that you call (as a dialog) in the OnOpen
event of the report?
 
J

Jeff Boyce

Andy

Good idea, but backwards...

Create a form you'll use to select criteria. You can use combo boxes or
list boxes to constrain which value users are able to select. If you need
dates, any valid date can be entered.

After the form is "completed" by the user, s/he will press a <Run the
Report> button. In the code behind this button, open the report. Base the
report on a query that looks to the form for its criteria.

Good luck

Jeff Boyce
<Access MVP>
 
B

Bob Howard

Open this form acDialog (in the OpenForm method) so that processing
temporarilly ceases in your report's OnOpen event until the dialog form is
either closed or becomes not visible to the user.

The way I handle this is to prompt the user in the dialog form and the user
clicks a button or something, have the OnClick event for that button simply
make the dialog form Visible=False. Control then returns to the next
instruction (right after the openform) in the report's OnOpen event --- but
the key is that the dialog form is still open (not visible, however).

The controls that the user entered data into are all there for the OnOpen
event to pull data out of ([Forms]![dialog name]![control name] etc.) ---
when I've gotten all I need, i issue a Close on the dialog form.

I also use an additional unbound and not-visible control in the dialog, and
give the user two buttons: "Print" and "Cancel" (or something like that).
Then in this control I set a switch telliing the report's OnOpen whether the
user decided to bail out or actually product the report.

Bob.
 

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

Top