For my example I will assume you have a field called OrderID and a control on your main form called txtOrderID. The OrderID is the primary key that links an order (one) to it's detail (many) items, and that it is a Number field type. I'm assuming that you want to view an order on the screen and then print that record/order using your report which now prints all records. I assume that you already have a button on your order form that calls the report up and shows you the report with ALL orders showing. (I would not have to assume as much if relevant data were included in the post, sorry.)
Look at the code for the print report button, you'll see a couple lines like this:
[tt]
Dim stDocName As String
stDocName = "MyReportName"
DoCmd.OpenReport stDocName, acPreview
[/tt]
The DoCmd.OpenReport command allows you to specify a where clause which allows you to limit a report being called to certain data "where x = y". We're going to modify this code to do that by changing it to this:
[tt]
Dim stDocName As String
Dim stDocWhere As String
stDocName = "MyReportName"
stDocWhere = "[OrderID] = " & txtOrderID
DoCmd.OpenReport stDocName, acPreview, , stDocWhere
[/tt]
Notice that I set the where clause to [OrderID] which is your fieldname = to the control on the form [txtOrderID]. Then I add the where claus to the OpenReport command.
HTH
Joe Miller
joe.miller@flotech.net