Thanks Steve,
This is along the lines of what I'm trying to do. Can I preview the report
rather than print it?
Regards
Dylan
"SteveS" <limbim53 at yahoo dot com> wrote in message
Hi Dylan,
Maybe this is what you are looking for.... at least it is another way. <g>
On a form, create an unbound list box and two buttons. One button will print
the reports and the second will clear the selected items in the list box.
---LIST BOX---
On the "Other" tab,
1) change the Multi Select" property to 'Simple'.
2) change the name of the list box to "mslbxSites".
(my naming convention:: "ms" = MultiSelect; "lbx" = listbox and "Sites" is
the field you are selecting)
On the 'Data' tab, set the row source to look like this:
SELECT DISTINCT SurveyData.[Site]
FROM Test Cases
ORDER BY SurveyData.[Site];
---FIRST BUTTON---
Name one button "btnPrintReport". Set the caption of this button to "Print
Report" (no quotes).
Paste the following code in the click event:
' ***********
Dim vItm As Variant
Dim strCriteria As String
strCriteria = ""
For Each vItm In Me!mslbxSites.ItemsSelected
strCriteria = Trim(Me!mslbxSites.ItemData(vItm))
'!!!!!! change "ReportName" to the name of your report. !!!!!!!!!
DoCmd.OpenReport "ReportName", , , "[Site] Like '" & strCriteria &
"*'"
Next vItm
' *****************
---REPORT-----
In the report query remove the "Where" clause. The query should look like
this:
SELECT SurveyData.[Date of Survey], SurveyData.Site, SurveyData.Element,
SurveyData.Condition, SurveyData.PriorityRef, SurveyData.[Revenue Cost],
SurveyData.[Revenue Comments], SurveyData.[Remaining Life],
SurveyData.[Capital Cost], SurveyData.[Capital Comments]
FROM SurveyData
ORDER BY SurveyData.[Date of Survey], SurveyData.Site, SurveyData.Element;
---SECOND BUTTON---
Name the second button "btnClearSelections".
Set the caption of this button to "Clear Selections" (no quotes).
Paste the following code in the click event:
' **************
Dim n As Long
For n = 0 To Me!mslbxSites.ListCount
Me!mslbxSites.Selected(n) = False
Next
' **************
HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)
dd said:
Sam,
I tried this with a listbox, but it doesn't pass my selection to the
query.
Also, I thought a listbox would let me select more than one Site, but it
doesn't.
Any ideas?
Dylan
I have a condition survey report based on this query.
Instead of a query asking for a site, I want a form which lists all the
available sites; allows the user to pick specific sites from the list,
and
then produce the report for each of the picked sites.
Hi Dylan,
Until someone offers a neater solution, you can try this:
1. On your form, build a combo box that will let the user choose a site
from a list.
2. Amend your query so that for the field 'Site' you set the criteria
to
=
![comboBoxControlName]
3. Use a wizard to create a button to launch the report.
The user will select a site, click the 'Print' button which will launch
your report based on yoru query, which has a where clause on the site
field...
I think think this is what you are asking for

If not slap me around
a little, and re phrase your request.
I am always happy to try and help!
Kindest Regards,
Sam