Access XP Reports PROBLEM !

  • Thread starter Thread starter Neel
  • Start date Start date
N

Neel

Hello ;

How can I Pass a parameter value from external source
such as VB6 script to the access 2002 report which is
based on a query, I need to Pass [ID] = 10
I have tried a few ways but it picks up all the records ,
I only need to report where ID = 10.

In the VB scipt I have :
---------------------------------------------------
..OpenReport strRptName,acViewPreview,,strWhere
..OutputTo 3,strRptName,"Snapshot Format(*.snp)",
snpflpth,-1
---------------------------------------------------
( NB : strWhere = "[ID] = 10" )

I am only trying to initiate a report to pull out ID = 10
records ,

Do I have to change anything in the report OR change the
query in some way so that the VB script passes the WHERE
clause with "[ID]=10" and the query or the report
recognises that it only has to report on the value of ID
= 10.

Can anyone help me OR point me to the right direction ???
I have tried this for 24 hours and am about to give up !!
Thank you ,
Neel.
 
Neel:

You don't indicate if the report opens properly in print preview, but only
fails when outputting the snapshot. Is this the case ordoes it fail even on
preview?

If its just on the snapshot, unfortunately, that's the expected behaviour.
When using OutputTo, Access does not pick up where clauses etc, when
outputting a snapshot; it refires the report fresh. There are two ways
around this, both generally involve the same type of solution.

1.) You can modify the report's underlying query to accept parameters and
then supply them via code using a user defined function within the query.
Stop by our web and in the Code and Design tips area under reports there's
an example of that approach.

2.) The second approach is to use the Filter and FilterOn properties of the
report. In that approach you need to add code to the report's On Open event
that will query a db module level variable through a function call, and if
that variable (a string) has length greater than 0, then apply that as the
report's filter in the On Open event and set Filter On = true. Then
create a second function in the db's general module that you can call from
your VB app (using the Application object's .Run command) to set the value
of the variable that your report will pick up.

HTH
 
Back
Top