Sending Form Data to a report

B

Bretona10

Hi, I have a form/subform setup as data entry, the subform is partially
populated based on drop down combo on the main form. I want to send the data
from this form/subform to a report. Like a snapshot, with only the records
that are actually on the form. The subform has a counter field as its Key.
Any simple ways to do this?

Thanks, Bret
 
J

John W. Vinson

Hi, I have a form/subform setup as data entry, the subform is partially
populated based on drop down combo on the main form. I want to send the data
from this form/subform to a report. Like a snapshot, with only the records
that are actually on the form. The subform has a counter field as its Key.
Any simple ways to do this?

Thanks, Bret

Sure. Open the Report from the click event of a button on the form; and use
the WhereCondition parameter of the OpenForm method to pass the ID of the
desired record.

DoCmd.OpenReport "YourReportName", WhereCondition := "[Keyfield] = " & Me!Key

using the actual fieldname of the key field in place of Keyfield and the name
of a control on the form containing that value in place of Key.
 
B

Bretona10

Hi John, would this code send all the records in the current subform to the
report?

John W. Vinson said:
Hi, I have a form/subform setup as data entry, the subform is partially
populated based on drop down combo on the main form. I want to send the data
from this form/subform to a report. Like a snapshot, with only the records
that are actually on the form. The subform has a counter field as its Key.
Any simple ways to do this?

Thanks, Bret

Sure. Open the Report from the click event of a button on the form; and use
the WhereCondition parameter of the OpenForm method to pass the ID of the
desired record.

DoCmd.OpenReport "YourReportName", WhereCondition := "[Keyfield] = " & Me!Key

using the actual fieldname of the key field in place of Keyfield and the name
of a control on the form containing that value in place of Key.
 
J

John W. Vinson

Hi John, would this code send all the records in the current subform to the
report?

No. You're making a very common mistaken assumption here!

The subform DOESN'T contain ANY records.
The report doesn't get any records from the subform.

The subform *is a window*, a tool to display data from a Table.
The report is also a tool that displayes data from a Table.

What you're passing to the report is a query criterion to tell the report
*which* records it should pull from the table. That query criterion is, in
this case, the same criterion that the form uses to specify which records
should be displayed on the subform - so that is the net effect (you see on the
report the same records you see on the subform), but it's important to
understand HOW that happens.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top