MS Access - Click Value on Report to Bring up Underlying Data

I have an access report that lists fields like ID, Date and Summary. I have used the following code to make the ID clickable to bring up a report on the selected record, but it is bringing up a blank report. Thoughts on how to make this work?

Private Sub ePMRef_Click()
DoCmd.OpenReport "Project Summary", acViewReport, , "[ePMRef]= '" & [ePMRef] & "'"

End Sub
Who is Participating?
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
try changing

DoCmd.OpenReport "Project Summary", acViewReport, , "[ePMRef]= '" & [ePMRef] & "'"


DoCmd.OpenReport "Project Summary", acViewPreview, , "[ePMRef]= '" & Me.[ePMRef] & "'"

if [ePMRef] is number type of data, use this

DoCmd.OpenReport "Project Summary", acViewPreview, , "[ePMRef]= " & Me.[ePMRef]
Jeffrey CoachmanMIS LiasonCommented:
<No Points wanted, as capricorn1 has already your question.>

Your clickable ID technique will only work if the report is in "Report View"
Report View will allow for interaction,  (and Filtering, ..etc)
...But it does have some potential drawbacks.
1. It may not render graphics (per record) correctly
2. Will not display accurate "Page x of y" numberings
3. It will not run any potential custom code on any Format events

In other words it will not give you a true "Print Preview"

To deal with this you can use a buttons on a form to decide what "view to open the report in:

DoCmd.OpenReport "YourReport", acViewReport
DoCmd.OpenReport "YourReport", acViewPreview

Again, no points wanted, just some extra info..


bezellviAuthor Commented:
Thanks - I got it. One other issue I'm having - a report footer is saying 1 of 10 pages when I go to print, but there are only 8 pages...
Jeffrey CoachmanMIS LiasonCommented:
This may be another, unrelated issue.

Since capricorn1 has answered you original question correctly, you should accept his post and create a new question for this new issue.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.