Opening a form invisible

  • Thread starter Thread starter RanceR
  • Start date Start date
R

RanceR

The post pertains to a posting I made Sept 23rd
entitled "Supplying param to subquery for report"

My problem was that I had a somewhat complicated series of
queries that needed to run to generate the input for a
report. The first subquery needed a parameter supplied to
it, but I didn't want to reference a particular control (a
combo box in this case) because this query, and several
that run after it, will be used as the basis for other
reports, forms and queries. I was looking for another way
to supply the parameter.

Duane Hookom's response was that I could open a form
invisible and set the control, then open the report.

I am not exactly sure what this means or how to do this.
Could Duane or someone else provide a little further
explanation?

Thanks.
 
RanceR said:
The post pertains to a posting I made Sept 23rd
entitled "Supplying param to subquery for report"

My problem was that I had a somewhat complicated series of
queries that needed to run to generate the input for a
report. The first subquery needed a parameter supplied to
it, but I didn't want to reference a particular control (a
combo box in this case) because this query, and several
that run after it, will be used as the basis for other
reports, forms and queries. I was looking for another way
to supply the parameter.

Duane Hookom's response was that I could open a form
invisible and set the control, then open the report.

I am not exactly sure what this means or how to do this.
Could Duane or someone else provide a little further
explanation?

Essentially, you're saying that you need a globally
available place to put the parameters.

One way this can be done is by using a form that never
becomes visible and parking your parameter values in the
form's text boxes which the query can then reference. As
part of the code to open report (from where ever), you would
first open the form using:
DoCmd OpenForm "ParamForm", _
WindowMode:= acHidden
and then copy the parameter values to the form's text boxes:
Forms!ParamForm.txtparam1 = firstparamvalue
. . .
Now the queries can get the parameters by using:
Forms!ParamForm.txtparam1
. . .


An alternate approach would be to define a bunch Public
variables in a standard module:
Public param1 As whatever
. . .
Next, in that same module, create a public function to go
with each variable:
Public Function GetParam1()
GetParam1= param1
End Function

Then, as part of the code to open report copy the parameter
values to the public varaiables:
param1 = firstparamvalue
. . .

With this approach, the query can get its parameters by
using:
GetParam1()
. . .
 
Back
Top