ACC: SetValue Action Does Not Set Value for Page One of Report

Last reviewed: May 30, 1997
Article ID: Q162537
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

When you run a macro that executes an OpenReport action, and then executes a SetValue action that sets the value for controls on the report being opened, the controls on the first page of the report are not updated by the SetValue action.

CAUSE

The SetValue action was executed after the report was opened. After the report is opened, it is too late to change the values for controls that appear on the first page. The SetValue action should be placed in a macro that is triggered from the Format event of the control's report section or the Activate event of the report.

RESOLUTION

Create a macro that contains the SetValue action and attach that macro to the Activate event of the report or the Format event of the control's report section. Then, the controls on the first page of the report will display the correct values.

MORE INFORMATION

The Activate event of the report occurs before the report's Format event. The Format event occurs when Microsoft Access determines which data belongs in a report section, but before the section is formatted for previewing or printing. Changes that affect the data that will be displayed in a report section should be placed in the Format event of that section or the Activate event of the report.

Steps to Reproduce Behavior

  1. Open the sample database NorthWind.mdb.

  2. Create a report using the AutoReport: Columnar Wizard based on the Categories table.

  3. Open the report in Design view and add an unbound textbox to the detail section. Change the Name property of this control to "txtDate" (without the quotation marks).

  4. In the detail section of the report, set the ForceNewPage property to After Section.

  5. Close the report and save it as "rptSetValue" (without the quotation marks).

  6. Create the following macro:

          Macro Name      Action
          --------------------------
          Test1           OpenReport
                          SetValue
    
          Test1 Actions
          -------------------------------------------
          OpenReport
             Report Name: rptSetValue
             View:        Preview
    
          SetValue
             Item:        Reports!rptSetValue!txtDate
             Expression:  Date()
    
    

  7. Save the macro as Test1 and run it.

    Note that the report opens but the date does not appear in the unbound textbox (txtDate) on the first page. On subsequent pages the date is displayed in the text box as expected.

REFERENCES

For more information about the order of events in reports, search the Help Index for "order of events," and then "Find out when events occur," or ask the Microsoft Access 97 Office Assistant.


Keywords : McrArg McrProb
Version : 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.