Coding text boxes on a report in access

I have a report (rpt_CustomerQuoteCategoryA) whose purpose is to display some information on a certain form (frm_GenerateQuoteCategoryA). The button on the form that opens this report has code to open the report as a preview, and to update all the text boxes on the report to correspond to the text boxes on the form. Here is the code:

Private Sub cmd_ViewReport_Click()

DoCmd.OpenReport "rpt_CustomerQuoteCategoryA", acViewPreview, , , acWindowNormal

Reports!rpt_CustomerQuoteCategoryA!txt_Price1 = Forms!frm_GenerateQuoteCategoryA!txt_Price1
Reports!rpt_CustomerQuoteCategoryA!txt_Price2 = Forms!frm_GenerateQuoteCategoryA!txt_Price2
Reports!rpt_CustomerQuoteCategoryA!txt_Price3 = Forms!frm_GenerateQuoteCategoryA!txt_Price3

When I run this code, the report opens but there is nothing in each text box. To make sure that access was reading the value, I added the following code:

'Debug.Print Reports!rpt_CustomerQuoteCategoryA!txt_Price1

Which verified that the value of the txt_Price1 text box was correct, but still does not display on the report.

Thanks for your help.

lericks3Asked:
Who is Participating?
 
peter57rCommented:
You need to pull the data into the report rather than push it from the form.

How you do this might depend on your report structure but you can try the Format event procedure for the report section containing the price controls.
me!txt_Price1 = Forms!frm_GenerateQuoteCategoryA!txt_Price1
me!txt_Price2 = Forms!frm_GenerateQuoteCategoryA!txt_Price2
me!txt_Price3 = Forms!frm_GenerateQuoteCategoryA!txt_Price3
0
 
KorbusCommented:
Hmm.. Can you "refresh" a report?
0
 
Jeffrey CoachmanMIS LiasonCommented:
lericks3,

Pete's post should solve you question directly.

Can I ask if the Form is bound to a table or query (Recordsource)?
If so, then why not base the report on the same recordsource as the Form?
Thus, avoiding the issue altogether?

If the form is unbound, then I understand you reasoning.
;-)

JeffCoachman
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
lericks3Author Commented:
Actually my form is pulling inforomation from a parameters form so I can't change the recordsource.

The me!txt_Price1 = Forms!frm_GenerateQuoteCategoryA!txt_Price1 solution did actually not work. I ended up changing the event procedure from on click of the form button to on load of the report.
0
 
peter57rCommented:
'from on click of the form button '

I don't think anyone said you should do it there.
0
 
Jeffrey CoachmanMIS LiasonCommented:
lericks3,

<my form is pulling inforomation from a parameters form so I can't change the recordsource.>

This really shouldn't matter.
But then again, I am not familiar with your database structure.

So, Problem solved?
0
 
Jeffrey CoachmanMIS LiasonCommented:
I think you accepted the wong post.

Wheather you rform is bound or not, Pete's Post is the answer.

;-)

Jeff
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.