report opens form runs query

  • Thread starter Thread starter javablood
  • Start date Start date
J

javablood

I haved looked as far back as fredg's 2005 response using Me.Visible = False
on a command button in a form to run a report but I get "You can't hide a
control that has focus"

So, I have a report from which a form is opened (On Open). The form allows
the user to input a beginning date from which a query returns records from
beginning date to present. The user then selects the dates for which only
those selected records will appear on a report.

From previous posts, I have been able to get all this to work except now
running (or returning to) the report once the dates are selected is not
working. Any suggestions will be greatly appreciated!

TIA
 
It is almost always best to put all your parameter values on your form and
reference the form controls from the report.

If you want to make the form visible when the report is run, do it in the
report's Open even
Forms!MyFormName.Visible = False

And you can make it visible again in the report Close event. But, usually,
I close the form because I am done with it.
 
Dave,

The form is opened when the report is opened and the parameters are input in
the form and referenced in the report. My problem is returning to the report
once the parameters are input and the queries run. I know this must be
elementary but Watson I’m stuck!
 
Perhaps I wasn't clear.
Don't open the report first, Open the parameter form, then put a button on
the parameter form to open the report once all the parameters have been
entered.
 
I haved looked as far back as fredg's 2005 response using Me.Visible = False
on a command button in a form to run a report but I get "You can't hide a
control that has focus"

So, I have a report from which a form is opened (On Open). The form allows
the user to input a beginning date from which a query returns records from
beginning date to present. The user then selects the dates for which only
those selected records will appear on a report.

From previous posts, I have been able to get all this to work except now
running (or returning to) the report once the dates are selected is not
working. Any suggestions will be greatly appreciated!

TIA

I have no idea 'which' of my 2005 responses you are using, but
I see you are trying to enter parameters using a form.

First create query that returns all of the records.
Then in the query add criteria to the [DateColumn]:

Between Forms!ParamForm!StartDate and Forms!ParamForm!EndDate

Save the query.
Add a new form to the database.
Add an unbound control.
Set it's format property to mm/dd/yyyy
Name this control "StartDate"

Add another unbound control to the form.
Set it's Format property to mm/dd/yyyy
Name this control "EndDate"
Add a command button to the Form.
Set it's Click event to [Event Procedure]
Then code it's Click event:
Me.Visible = False

Now create a report (or use your current report).
Set it's RecordSource to the query.
Code the Report's Open event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the Report's Close event:
DoCmd.Close acForm, "ParamForm"


When ready to run the report, open the Report.

The report will then open the form and await your filling in the start
and end dates.
When you click the form's command button the form will become not
visible and the report will run.
When the report is closed it will also close the form.
 
Fred,

The exact 2005 response does not matter and you covered this issue in
numerous posts through out the years. I am a bit slow at this so please bear
with me. Are you suggesting that I create a new form (other than the form in
which I run the query and enter parameters) from which to run the report ? I
was trying to use the one form to do all this. If your answer is 'yes', why
cannot this be accomplished on the one form. If your answer is 'no', why am
I getting the "You can't hide a control that has focus" error?

--
javablood


fredg said:
I haved looked as far back as fredg's 2005 response using Me.Visible = False
on a command button in a form to run a report but I get "You can't hide a
control that has focus"

So, I have a report from which a form is opened (On Open). The form allows
the user to input a beginning date from which a query returns records from
beginning date to present. The user then selects the dates for which only
those selected records will appear on a report.

From previous posts, I have been able to get all this to work except now
running (or returning to) the report once the dates are selected is not
working. Any suggestions will be greatly appreciated!

TIA

I have no idea 'which' of my 2005 responses you are using, but
I see you are trying to enter parameters using a form.

First create query that returns all of the records.
Then in the query add criteria to the [DateColumn]:

Between Forms!ParamForm!StartDate and Forms!ParamForm!EndDate

Save the query.
Add a new form to the database.
Add an unbound control.
Set it's format property to mm/dd/yyyy
Name this control "StartDate"

Add another unbound control to the form.
Set it's Format property to mm/dd/yyyy
Name this control "EndDate"
Add a command button to the Form.
Set it's Click event to [Event Procedure]
Then code it's Click event:
Me.Visible = False

Now create a report (or use your current report).
Set it's RecordSource to the query.
Code the Report's Open event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the Report's Close event:
DoCmd.Close acForm, "ParamForm"


When ready to run the report, open the Report.

The report will then open the form and await your filling in the start
and end dates.
When you click the form's command button the form will become not
visible and the report will run.
When the report is closed it will also close the form.
 
Dave,
I actually started out that way but when I saw fredg's post I thought it was
worth a try. However, when I went back to running report from the form I get
Error '3070' MS Office Access database engine does not recognize " as a valid
field name or expression and it refers to this: DoCmd.OpenReport "rpt_NWBA",
acViewPreview

??
 
Back
Top