Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jan 2003
    Location
    USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Global Report Variable (Access 2002)

    Hi everyone, I have a procedure on the on format event of the detail section of a report. Within this I am accumulating some totals to be printed at the report footer section. I cannot get this to work. How
    can I get the variables to be printed at the footer level? Any help
    appreciated.....Steve

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Global Report Variable (Access 2002)

    You can declare a variable at the top of the report module. It can be used in any procedure/function in the report module, so you could update its value in the On Format event of the detail section, and use its value to populate a text box in the On Format event of the report footer.

    You can also use a textbox in the report footer with a control source of the form =Sum(some_expression) where some_expression can be a field name or a calculation.

    And you can use a text box in the detail section (hidden if you like) with its RunningSum property set to Over All. It will keep a running sum of the expression in its control source. You can refer to the value of this text box in the report footer; it will display the final value of the running sum because the report footer is formatted after all detail section have been processed.

  3. #3
    New Lounger
    Join Date
    Jan 2003
    Location
    USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Global Report Variable (Access 2002)

    I have Dim ProfitBaseSales As Double in the General Declarations. Within the on format of the detail section I am accumulating to this variable. In the report footer I have a text box that has ProfitBaseSales as the control source. Is this not correct?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Global Report Variable (Access 2002)

    No, you can't refer to a variable directly in the control source of a text box. You can populate the text box in two ways:

    1. Define a function

    Function GetProfitBaseSales()
    GetProfitBaseSales = ProfitBaseSales
    End Function

    and use this function in the Control Source of the text box:

    =GetProfitBaseSales()

    - OR -

    2. Set the value of the text box in the On Format event of the report footer:

    Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    MyTextBox = ProfitBaseSales
    End Sub

    where MyTextBox is the name of the text box in the footer.

  5. #5
    New Lounger
    Join Date
    Jan 2003
    Location
    USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Global Report Variable (Access 2002)

    Thank you Hans! It seemed logical to me that I could reference the variable as the control source. Thank you for correcting me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •