Open a report by clicking on a record

nadoona

Registered User.
Local time
Today, 12:34
Joined
Jul 17, 2004
Messages
11
Hi all,

I've a from that contains a combo box and a subform. The combo box is used for searching in a certain table. In other words, after choosing a value from the combo box, I get all the records related to this value. This part is working very well. Now my question is: is there a way to open a report by choosing a record from the subform. I mean is there a way to open a report just by clicking on a record from the subform (the subform is in a Datasheet view). Of course the report has to be the one related to the record I chose. For example, when I click on the record whose OrderNo is 123, I want to get the report for the invoice No 123.

Thanks a lot for ur time.
All replies are appreciated.
 
The double-click event is more appropriate for this. You don't want the report to be generated every time someone clicks into a field.

The easiest way to do this is to add a button to the subform. The button wizard will give you the option of opening a report based on the current record. You will need to add one line of code to this generated code. The current record must be saved prior to opening the report. So, directly in front of the OpenReport method, add the following:

DoCmd.RunCommand acCmdSaveRecord

If you would rather use the double-click event of some field, just copy the code from the button.
 

Users who are viewing this thread

Back
Top Bottom