Queries and Constants

MikeAngelastro

Registered User.
Local time
Today, 07:55
Joined
Mar 3, 2000
Messages
254
When ever I try to use a constant in a Query, the query treats it as a parameter. It asks the user to provide a value. Is this the way Access is designed? Or am I doing something wrong? Will I have to use a public function in order to use the constants?
 
The constants are part of VBA. SQL is a "language" designed to work with relational tables not a programming language and not part of VBA. Microsoft has made some extensions to the standard language definition implemented by all the RDBMS manufacturers so that Jet can evaluate VBA and user defined functions. To use a value that is stored as a variable or constant in VBA code, you can write a function to return it.

Some function:
Public Function MyFunction()
MyFunction = SomeValue
End Function

A query:
Select Fld1, Fld2, etc.
From YourTable
Where Fldx = MyFunction();
 
Thanks Pat. That's what I thought. It appears that the same is true for forms and reports as well.
 

Users who are viewing this thread

Back
Top Bottom