Structure your tables as John describes and base the report on a query
joining them. To select multiple customers and open the report create an
unbound form with a multi-select list box of all customers with CustomerID as
the hidden bound column, but showing the customers by name. To do this set
up the list box like this:
For its RowSource property:
SELECT CustomerID, Customer FROM Customers ORDER BY Customer;
For other properties:
Name: lstCustomers
BoundColumn: 1
ColumnCount: 2
ColumnWidths: 0cm;8cm (or rough equivalent in inches but the first
dimension must be zero to hide the first, CustomerID, column, so only the
name shows.
MultiSelect: Simple or Extended as preferred.
Add a button to the form to open the report, called rpt Customers in this
example, with the following in its Click event procedure:
Dim varItem As Variant
Dim strCustomerIDList As String
Dim strCriteria As String
Dim ctrl As Control
Set ctrl = Me.lstCustomers
If ctrl.ItemsSelected.Count > 0 Then
For Each varItem In ctrl.ItemsSelected
strCustomerIDList = strCustomerIDList & "," &
ctrl.ItemData(varItem)
Next varItem
' remove leading comma
strCustomerIDList = Mid(strCustomerIDList, 2)
strCriteria = "[CustomerID] In(" & strCustomerIDList & ")"
DoCmd.OpenReport "[rptCustomers]", _
View:=acViewPreview, _
WhereCondition:=strCriteria
Else
MsgBox "No Customers Selected", vbInformation, "Warning"
End If
The above will open the report in print preview, so you might want a second
button on the form with slightly amended code ( simply remove the
'View:=acViewPreview, _' line) to print the report.
Ken Sheridan
Stafford, England