Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / January 2007

Tip: Looking for answers? Try searching our database.

Filter question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vsn - 27 Dec 2006 16:26 GMT
Hi All,

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.

Thx a lot,
Ludovic
Rick Brandt - 27 Dec 2006 16:44 GMT
> 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.
[quoted text clipped - 27 lines]
> 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.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

Vsn - 31 Dec 2006 06:00 GMT
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 Brandt - 31 Dec 2006 13:41 GMT
> 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.
Jeff C - 27 Dec 2006 18:55 GMT
A different approach would be to have a query that reflects the same
record source as your form only add criteria to an ID field in the
query so that it reflects the current record on the form ie:
forms!myform.txt_ID

Simply base your report on this new query and open with your command
button

> Hi All,
>
[quoted text clipped - 79 lines]
>
> ------=_NextPart_000_0170_01C729F5.418FFBF0--
Vsn - 01 Jan 2007 05:41 GMT
Jeff, I have managed to do what I was looking for thx for your help.

Ludovic
>A different approach would be to have a query that reflects the same
> record source as your form only add criteria to an ID field in the
[quoted text clipped - 99 lines]
>>
>> ------=_NextPart_000_0170_01C729F5.418FFBF0--
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.