How to use public variables in a query field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JaketheSnake27
    New Member
    • Sep 2010
    • 6

    How to use public variables in a query field

    I'm trying to define a field in a query using an expression. Part of that expression involves using public variables. First of all, is it possible to use variables in a query field? And if it is, what is the proper syntax for doing so?

    Example: (This is in the query design. [Delivery Lead Time] is a current field in the query. EPEI and DC are the variables I want to use to calculate the LTR.)

    LTR: [Delivery Lead Time]+"EPEI"+"DC"

    (Access doesn't recognize EPEI and DC when I enter it in this way. I have defined EPEI and DC as public variables in VBA.)

    Thanks in advance!
  • patjones
    Recognized Expert Contributor
    • Jun 2007
    • 931

    #2
    I would probably do one of two things.

    One possibility would be to just write the query out using SQL in VBA entirely, and then you'll have access to whatever you want.

    The other possibility is that you can write a function in a global VBA module to perform the desired calculation. In query design view you'll find that you have access to that function.

    Pat

    Comment

    • JaketheSnake27
      New Member
      • Sep 2010
      • 6

      #3
      I'll have to try those and see how it goes. Thanks!

      Comment

      Working...