-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
All reports require a RecordSource of a query or a table, therefore
you can't use the values of a ListBox as the RecordSource of a report.
You could create a query that fulfills the requirements of the report
then, using VBA, change the report's Filter & FilterOn properties in
the report's OnOpen event to show only those items selected in the
ListBox.
Order of events
1. Open report
2. Get selected items from the ListBox
3. Set the report's Filter to the items from the ListBox
4. Set the report's FilterOn = True
5. Continue opening the report
Example of Filter (VBA):
Me.Filter = "ID In (1,2,3,4,5)"
Me.FilterOn = True
Instead of using "ID=1 OR ID=2 ..." it is easier to use the In clause.
- --
MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBP43B7YechKqOuFEgEQK2egCeJgA7KUcOq6xPVXetfbxgBm xfZwUAn3xC
C/tDqesbVRjJiiQOJrp+JzfF
=lsLA
-----END PGP SIGNATURE-----
louise wrote:
hi
i am trying to set up a mail merge button which takes records from a
multi-select listbox (the contents of which are decided by a query
created by a search from) and not from a specific query.
I have a function GetCriteria()
Private Function GetCriteria() As String
Dim stDocCriteria As String
Dim VarItm As Variant
For Each VarItm in lstBox.ItemsSelected stDocCroteria =
stDocCriteria & "[ID] = "& lstBox.Column (0,VarItm) & "OR"
Next
If stDocCriteria <> " " Then
stDocCriteria = Left(stDocCriteria, Len(stDocCriteria) -4)
stDocCriteria = "True"
End If
GetCriteria = stDocCriteria
End Function
I also have a button to open a report and another to open a form,
these use
DoCmd.OpenReport "RptIndividualContacts" acPreview,,GetCriteria()
This works fine but i want to be able to use mail merge in the same
way. Also i want to create mailing labels but a button to the
mailinglabel report needs to be linked to a query.
Can anyone help?
thanx
lou