Coding text boxes on a report in access

Posted on 2009-04-20
Last Modified: 2013-11-28
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.

Question by:lericks3
    LVL 10

    Expert Comment

    Hmm.. Can you "refresh" a report?
    LVL 77

    Accepted Solution

    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
    LVL 74

    Expert Comment

    by:Jeffrey Coachman

    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.


    Author Comment

    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.
    LVL 77

    Expert Comment

    'from on click of the form button '

    I don't think anyone said you should do it there.
    LVL 74

    Expert Comment

    by:Jeffrey Coachman

    <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?
    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    I think you accepted the wong post.

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



    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now