I have a data entry form which consists of three forms
1- Main form (customer) 2- Sub form (order) 3- Sub form (order details)
the order details sub form is linked to order sub form, also the order sub form is linked to the customer form. I created a report by wizard with customer record set, and then dragged the order records to the report by using "from existing table". Finally, i created a sub report for the order details. From the data entry form, when i click the order sub form record, the corresponding fields of the order details shown only, and that fits my need. Well, I created a command button to print the selected records. I built. The command button has the following code
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Please select a record"
Else
strWhere = "[CustomerID] = " & Me.[CustomerID]
DoCmd.OpenReport "rptcustomers", acViewPreview, , strWhere
End If
End Sub
However, when i select the the second row of the order in the data entry form which is refer to the second order of a customer, the report show all the orders and their details of that customer. I want only the selected order and its details printed. Can any help please. I explained what i did step by step just to be clear to the reader.