Constants used in query criteria

D

Dave Griffiths

Can anyone help me to do the following - I want to create a system wide
constant that I can use as part of a series of query crieria?

I tried putting the line - public const kkTest as long = 10 - in a module
but when I try to put something like - >kktest - in a criteria then
kktest gets automatically surrounded by speech marks and is treated as a
string

Any help much appreciated
Dave
 
J

John Vinson

I tried putting the line - public const kkTest as long = 10 - in a module
but when I try to put something like - >kktest - in a criteria then
kktest gets automatically surrounded by speech marks and is treated as a
string

VBA and SQL are two separate domains - VBA variables are not
accessible to SQL queries.

Two suggestions:

- Put the kkTest value in a Table and eitehr link it as part of your
query, or use DLookUp() to find it as a criterion

- Write a dumb little function to get the variable:

Public Function GetKKTest() As <appropriate datatype>
GetKKTest = kkTest
End Function

and use GetKKTest() in your criterion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top