Show Mult-Select selections in Textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a multi-select list that filters my report but how do I show what the
user has selected in a textbox on the report?

Thanks!
 
You probably have some code that loops through the ItemsSelected collection
of the list box to build up the string to use in the WhereCondition of
OpenReport? Something like this example:
http://allenbrowne.com/ser-50.html

If so, you can then display the string on the report with a text box that
has its ControlSource set to:
=[Report].[Filter]
The trouble is that Access will show the filter, wheter it is applied or
not. And you can't solve that problem by testing the FilterOn property,
because Access does not maintain that property reliably.

In Access 2002 or 2003, you could also pass the string (or a better English
description if you prefer) in the OpenArgs of the report, and show it as:
=[Report].[OpenArgs]
In earlier versions, you could pass it through a public string, and assign
it in the Format event of the Report Header section.
 
Thanks Allen, that should work (Ill try it in a minute)
I have another question now that came up.
In my listbox i have all the different areas to choose from and then I have
"ALL" in the list also.
Im trying to figure out how to do something like this:

If strCriteria = LIKE ",'ALL'" then ...
(It works fine if i dont use LIKE but I need it to work if the user
selects more from the list than just "ALL")

But I can't seem to get the LIKE statment to work in vb.
Any Ideas?

Thanks

Allen Browne said:
You probably have some code that loops through the ItemsSelected collection
of the list box to build up the string to use in the WhereCondition of
OpenReport? Something like this example:
http://allenbrowne.com/ser-50.html

If so, you can then display the string on the report with a text box that
has its ControlSource set to:
=[Report].[Filter]
The trouble is that Access will show the filter, wheter it is applied or
not. And you can't solve that problem by testing the FilterOn property,
because Access does not maintain that property reliably.

In Access 2002 or 2003, you could also pass the string (or a better English
description if you prefer) in the OpenArgs of the report, and show it as:
=[Report].[OpenArgs]
In earlier versions, you could pass it through a public string, and assign
it in the Format event of the Report Header section.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Joel said:
I have a multi-select list that filters my report but how do I show what
the
user has selected in a textbox on the report?

Thanks!
 
If you do add "ALL" as an item in the list box, it's best to parse it out in
your loop, so that there are no unnecessary criteria the JET must handle to
retrieve the records for the report.

In other words, if "ALL" is selected, set the WhereCondition to a
zero-length string, and exit the loop that handles the ItemsSelected.
 
Setting the textbox to the report filter worked.

I have never used a where statment before, so I have no idea how to code
this part into my loop, if you could help me out with it that would be great.

here is my loop:

FOR EACH varArea IN Me!List2.ItemsSelected
strCriteria = strCriteria & ";'" & Me!List2.ItemData(varArea) & "'"
NEXT varArea

Thanks!
 
Back
Top