Report Filtering

lekmall

Registered User.
Local time
Today, 13:35
Joined
Jan 19, 2004
Messages
24
Help please.
I have a report that is based on a query which selects all the records in the table. Sometimes, though, the user will want to select certain records from a listbox and then see the report.

I have tried setting the report filter property to a public variable - strvar - which contains the highlighted choices from the list box.
When I open the report, I use:

DoCmd.OpenReport "rptShortReport", PrintMode,, strvar

I've even tried changing strvar to be in the format of fieldname = 'xxx', fieldname = 'yyy', etc.

No luck!
 
Is the listbox in multi-select mode, where the user can highlight more than one item on the list. If not, and they can only select one item on the list, you can add a criteria in the query that the form is based upon.

What you have to be able to do though is provide the user the ability to not select any item on the list. Filtering though should work.
 
Thanks, thePrez.
I do allow the user to not have to select from the listbox because I have 2 radio buttons - one for 'All' and one for 'Selected'. The report query is 'Select * from ...'.

How can I change the query if the user selects certains items in the listbox?
 
If the user can choose only one item from the list box (or hell, maybe Access is smart enough to automatically generate an OR for multiple selections, but I doubt it) then reference the list box in the query criteria.

Meaning, the field in the query that matches the items in the list box should have its criteria set to reference the list box. It will look like this:


=[Forms]![NameOfMyFormThatContainsTheListBox]![NameOfMyListBox]
 
Thanks, Kraj
Much appreciated.
and yes..I will try to make it look pretty.....
 

Users who are viewing this thread

Back
Top Bottom