By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,657 Members | 862 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,657 IT Pros & Developers. It's quick & easy.

How to use public variables in a query field

P: 6
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!
Sep 14 '10 #1

✓ answered by patjones

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

Share this Question
Share on Google+
2 Replies


patjones
Expert 100+
P: 931
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
Sep 14 '10 #2

P: 6
I'll have to try those and see how it goes. Thanks!
Sep 15 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.