You need to pass a parameter to the report. I am not sure what you PK field is on the form. DO something like this:
Dim stDocName As String
Dim iPKID AS Integer 'if it is an autonumber field, for example
Dim sLink As String
iPKID = Me.PKID
sLink = "[PKID] = " & iPKID
stDocName = 'rptYourReportName"
DoCmd.OpenReport stDocName, acPreview, , sLink
You will have to confirm the syntax for the DoCmd line, but you want the link in the WHERE section. Place a button on your form called "Preview Report" and put this code on the On Click event.
Alternatively, if your report is based on a query, in the query design view, in the PK field criteria section put this criteria:
[Forms]![frmYourForm].[YourPKIDControlName]
Then on the form, create a button to open the report and don't modify the code. When the query runs, it will pull the PK ID from your form and only open the report with the contents of the current form/subform data.
HTH
mmcdonal
|