How can I use VBA to retrieve a pivot table value within a query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DrDarwin
    New Member
    • Jun 2010
    • 3

    #1

    How can I use VBA to retrieve a pivot table value within a query?

    I would like to use the 'grand total' value of a pivot table generated from (or within) a query in an equation. I am unfamiliar with how to call upon that value using VBA or SQL (through VBA).

    It seems like it should be a simple operation, but I cannot find reference to it anywhere.

    I am using Access 2007 on a WinXP machine.

    Thank you in advance.
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    If you open your form in design view you should see the control that corresponds to the GrandTotal Value. This control can be referenced in VBA as follows:

    Code:
    'if referenced from the current form
    Me!ControlName
    
    'if referenced from another form or module
    Forms!NameOfForm!ControlName
    In other words you reference controls on a pivot form the same way you would controls on any other form.

    Comment

    • DrDarwin
      New Member
      • Jun 2010
      • 3

      #3
      What if the value I am trying to recieve is in a query rather than a form?

      Comment

      • DrDarwin
        New Member
        • Jun 2010
        • 3

        #4
        I built the pivot table into a form, and tried what you suggested (to the best of my ability). I'm still not getting the syntax right in order to identify the value in the attached image. It seems like it should be simple, but it's just beyond my grasp.
        Attached Files

        Comment

        Working...