Highlight sub form record (datasheet) to open a report

irish634

Registered User.
Local time
Yesterday, 19:00
Joined
Sep 22, 2008
Messages
230
Ok... so I am having a brain fade today.

I have a form that has a few command buttons and a sub form. The main form is not tied to any record source.

My sub form has a record source and I have it set up to be in datasheet view.

What I am trying to accomplish is:
When I select a record in the sub form, then click a "report" button on the main form, I want to open the report for the record highlighted.

I had thought I had an example of how this is accomplished but can't seem to find it. Can anyone point me in the right direction for this?

Thanks,
Craig
 
In the click event of the button put:

Code:
Screen.PreviousControl.Select

DoCmd.OpenReport "YourReportName", acViewPreview, , "[YourIDFieldOnReport]= " & Me.YourSubformContainerName.Form!YourIdFieldOnSubForm
(air code, but it should work)
 
In the click event of the button put:

Code:
Screen.PreviousControl.Select

DoCmd.OpenReport "YourReportName", acViewPreview, , "[YourIDFieldOnReport]= " & Me.YourSubformContainerName.Form!YourIdFieldOnSubForm
(air code, but it should work)

Thank you.
I was using:
Code:
Forms![MyMainForm]![MySubForm].Form![RecordID]
And it was not working correctly.
(Told you I was having a brain fade) :D

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom