I have a form with the following code in a command button. I would like to
print that current record onto a report. It prints out the record on the
report but it also prints the all the records form the form. Does anyone
know what I'm doing wrong here?
Thanks.
Private Sub Command217_Click()
On Error GoTo Err_Command217_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "aaa"
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenReport stDocName, , , stLinkCriteria
DoCmd.DoMenuItem acFormBar, acFile, 6
Exit_Command217_Click:
Exit Sub
Err_Command217_Click:
MsgBox Err.Description
Resume Exit_Command217_Click
End Sub
Patrick Stubbin - 29 Nov 2005 02:27 GMT
I suspect that the underlying query for the report is too broad....

Signature
Regards
Patrick Stubbin
> I have a form with the following code in a command button. I would like to
> print that current record onto a report. It prints out the record on the
[quoted text clipped - 23 lines]
>
> End Sub
Compuhelpmt - 11 Dec 2005 23:47 GMT
Yes, your query needs to be changed. In the criteria area of the primary key
field in the query design, enter the Forms!Nameofform fieldname
When you run the report, it will get the info from the query, which looks at
your form for the record you are highlighted on.
>I have a form with the following code in a command button. I would like to
> print that current record onto a report. It prints out the record on the
[quoted text clipped - 23 lines]
>
> End Sub