Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send form query results to Report

Status
Not open for further replies.

nhtraven

Technical User
Dec 10, 2000
114
US
I have a form, it's controlsource is a query. I have made a report, for each field in the report i have this in each field control source = [forms]![frmone]![fieldname] for each field tying to the corresponding field in form. This worked fine for my individual report, but the summary needs more then the first record. how would i go about sending all of the records to the report? would i save the recordsource? i am not sure how to do this

Any help is very much appreciated

Raven
 

hi,

In the 'Open' event of your report, write and try this:


me.recordsource = forms![<NameOfYourForm>].recordsource


... and as field record source write the field query name and NOT the reference to the form fields.

This should work
jeff

 
tsetse

Thanks, i tried this, but in this query that form is based on, it has a user prompt that user has already entered to get the records on the form, when i set reports record source to form it asks for the user to input the prompt again. is there a way around this? i tried to declare a global variable to accept the user input < but i am not sure how to get it>,
thanks
Raven
 
Raven, perhaps there is a more efficient way.

Set the report's data source to the query on which your form is based and the control sources to the individual fields of that query.

Then, on running the report (I assume it launches from a command button) pop up a form which prompts the user for a choice: Either print current record or Print full recordset. The easiest way is to have a button for each option.

The 'full set' button should run this code from it's click event

Code:
'Open Report with all data displayed
DoCmd.OpenReport &quot;YourReportName&quot;

The 'current record' button should have this code:

Code:
'Restrict data to match currently selected record on form
DoCmd.OpenReport &quot;YourReportName&quot;, acViewPreview, , &quot;[UniqueIDField]=&quot; & Forms![MyForm]![UniqueIDField][code]

You'll probably want to insert a close command for your selector form too.
 Robbo ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top