Rick, thx for your advice. I never got the hang of the diffrence of the Filter and the Where clause, and still not completely...
Now after your advice I did put my arguments in the Where Clause as I used to do, but it does not appear in the Filter in the report (so that I can turn it on or off). Can the Filter only be from within the report and than turned on?
Thx,
Ludovic
Vsn wrote:
> I do try to open a report with a command button from a form, the
> report should be filtered depending on the users choice on the form.
>
> FORM
>
> Private Sub cmdPrint_Click()
> Dim stgFilter As String
>
> 'Filter not transfered ??????????
> stgFilter = "([Type] = '" & Me.lstProject & "')"
> DoCmd.OpenReport "rptPojectOffshore", acViewPreview, stgFilter
>
> End Sub
>
> When opening the report the filter seems not to work? Even the first
> attempt to print the filter gives no (blanc) return.
>
> REPORT
>
> Private Sub Report_Open(Cancel As Integer)
>
> 'On Error Resume Next
>
> Debug.Print "Filter: "; Me.filter
>
> End Sub
>
>
> Who can I get my Filter working?
>
> I have never realy understood the diffrence between using a filter or
> the WHERE clause.
That lack of understanding is the issue. Move your stgFilter variable into the WHERE argument and out of the FILTER argument. The filter argument is meant to hold the name of a query to be used instead of the report's normal RecordSource.
In all my years of using Access I have never once used the Filter argument. Only the WHERE argument. It is a bit confusing because the WHERE argument actually "filters" the report and you will see it in the report's filter property. The same does not happen when using the FILTER argument.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
> Rick, thx for your advice. I never got the hang of the diffrence of the Filter
> and > the Where clause, and still not completely...
[quoted text clipped - 3 lines]
> it on or > off). Can the Filter only be from within the report and than turned
> on?
Not sure if you can do what (it appears) you want.
The Filter property as set by the WHERE argument of the OpenReport method is not
available yet in the Open Event of the Report, but is in later ones. I tested
the Page event and the Report Header Format events and the filter was available
there. However; it doesn't look like those later events can be used to turn the
filter on and off.
I must say that I have never had this requirement. Normally the code that is
opening the Report decides whether a filter should be applied, not code in the
Report itself.
I HAVE applied filtering in the Open event of a Report, but never in a
circumstance where I needed to also test whether the Filter property already had
been populated. I normally am testing some other condition like the value of a
control on an open Form or of a variable.

Signature
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Vsn - 01 Jan 2007 05:40 GMT
Rick,
My idea was to create a report that would function as stand alone as well as
being fired from a form, the text in the header of the report should depend
on the way (filter) it is opend. I now solved this by using the Argument.
Thx for the help provided.
Ludovic
>> Rick, thx for your advice. I never got the hang of the diffrence of the
>> Filter and > the Where clause, and still not completely...
[quoted text clipped - 20 lines]
> already had been populated. I normally am testing some other condition
> like the value of a control on an open Form or of a variable.