Print command button on subform

velcrowe

Registered User.
Local time
Yesterday, 19:38
Joined
Apr 26, 2006
Messages
86
I have a subform in my main contracts form for each record that I enter against my main contract. I would like to print each record in the subform without having to enter in the subform number. I created a print button that shows for every record entered in the subform. I've set the query criteria to look for the subform and print the record. When I open the subform on its own the button works for each record. When I open the main form that the subform is embedded in, it prompts me to enter the record from the subform although the main form is open with the subform activated. How can I fix this?
 
docmd.openreport "report name", acpreview
 
So, in the report's RecordSource are you referencing the form somehow?

You should be able to open the report like:

DoCmd.OpenReport "YourReportName", acViewPreview, , "[YourIDField]=" & Me!YourIDFieldOnForm

without referencing anything in the report's recordsource.
 
Should I remove the reference of subform in the query the report is built on?

Right now in the criteria of my id field its [forms]![frmsubform]![id]. Should I remove this so that I am not prompted for this information. The code you sent will reference it at the form/report level without needing the criteria in the query, correct?
 
Should I remove the reference of subform in the query the report is built on?

Right now in the criteria of my id field its [forms]![frmsubform]![id]. Should I remove this so that I am not prompted for this information. The code you sent will reference it at the form/report level without needing the criteria in the query, correct?

Yeah, remove the reference from the query and then use the type of way I provided and you don't have to have the criteria on the query.
 

Users who are viewing this thread

Back
Top Bottom