Report Offensive Message

One solution with button in the form
Solution is in using wherecondition argument on DoCmd.OpenReport. Assuming I want to use a button, click on EVENT and add the follwing VBA code:

Private Sub cmdPreviewRpt_Click()
Dim strReport As String
Dim strWhere As String

strReport = "My report name here"
strWhere = "[Name of my primary Key Field here] = """ & Me![Name of my Primary Key Field] & """"

DoCmd.OpenReport strReport, acViewPreview, , strWhere

End Sub

If primary key field is numeric you change strWhere sentence to:

strWhere = "[Name of KeyField] = " & Me![Name of KeyField]
Posted by haarsaker
20th Feb 2007