link command button to a specific record in report

  • Thread starter Thread starter JLew
  • Start date Start date
J

JLew

I created a command button in a form. When you click on
it, it opens up the correct report, but doesn't go to the
specific record that currently shows in my form. How do
I make that happen?

Thanks!
 
You can modify the code behind the command button:
Dim strWhere as String
strWhere = "[YourPKField]=" & Me.[txtYourPKField]
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere
If your primary key field is text then use:
strWhere = "[YourPKField]=""" & Me.[txtYourPKField] & """"
 
Back
Top