Dsiplay selections from a listbox on a report

G

Guest

I have created a multi select listbox which works great for both a query and
a report based on the query.

I now want to display what records were selected in the listbox in the
report header section of the report.

Any clues??
 
J

John Spencer

If you are using a multi-select listbox to set criteria for a query, then
you must be building the criteria string. You should be able to use that
string (or build another string at the same time).

Once you have the string to use in the report, you could do one of the
following
-- Save it to a control (visible property = false) on the form and reference
the form's control on the report.
-- Pass it to a parameter in the query (a calculated field in the query as a
parameter)
-- Set a global variable that the report can access
-- Use the OpenArgs property of the report (2002? and later versions)
 
G

Guest

Set your list box selections to strSelected and their description to OpenArgs

Good example is on Allen Browne’s website http://allenbrowne.com/tips.html

Then in your report OnOpen event code the following:

Private Sub Report_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Me.OrderBy = "[1stField] & [2ndField] &… [nthField]"
Me.OrderByOn = True
End If
End Sub

HTH,
Scruffy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top