Passing Parameters to Reports in Access 2000

  • Thread starter Thread starter Larry Stewart
  • Start date Start date
L

Larry Stewart

I am using Access 2000 and I am trying to pass parameters
to a report. The report generates SQL based on a
parameter, which is all done in a code module.

In Access 2002, I used the OpenArgs options on the
docmd.openreport command. I have been able to achieve the
results by putting the call to the code module within the
report_load event. However, I have to hardcode the form
in which the parameters are on. While this works, it
doesn't work if I want to call the report from another
location.

Is there anyway in Access 2000 to pass parameters to a
report? Please note the filter and where arguments will
not work since Access uses these internally.

Thanks,

Larry
 
I would suggest that you do in fact resort to using the were clause.

That way, you don't hard code any parameters in the sql.

If you take a look at the following screen shots, virtually every report run
from these screens uses the where clause. I think that is your best
solution:

Those screens:

http://www.attcanada.net/~kallal.msn/ridesrpt/ridesrpt.html

I suppose you can also always pick up the name of the active form in the
reports on-load:

Option Explict
dim frmPrevious as Form

In the on-load of the reprot, you get:

set frmPrevious = Screen.ActiveForm

Now, anywhere in the reprot code, you can use the previuos form:

frmPrevious.Name
frmPrevious.MyCustomMethoed

etc. etc.
 
Albert,

Thank you for the suggestions. The Where and Filter
criteria will not work because actual values within the
SELECT statement and pulled from another data source and
the used in calculations within the SELECT.

Therefore, the SQL is dynamically built from this other
data source, along with dynamically building the WHERE
clause, and then set to the RecordSource property.

I did receive a suggestion to use a hidden form and/or a
global collection. I believe that will solve my issue
until we move to Access 2002 that has the OpenArgs option.

Thanks again!

Larry
 
Back
Top