Parameters as global variables

Mikezy56

New member
Local time
Today, 22:41
Joined
Mar 4, 2013
Messages
8
Can I use a global variable as a parameter in a query please:(:(:(:(:(:(
 
Could you explain the situation in a bit more in detail?
 
Can I use a global variable as a parameter in a query please:(:(:(:(:(:(

There are ways to pass parameters, but more detail will be required in order for us to determine how any of them would apply for you. Please tell us more about what you are trying to do.
 
I have declared a public variable thus :-
############################################
Public MasonicOrder as integerMasonicOrder=1 @ The default value
############################################
In Module 1 of my VBA for Access.
Can I type :-
#############################################
[MasonicOrder]
#########################################
In the = field of a query to create a parameter query and would the query use the value of the global variable to set select matching records
 
you cannot use the public variable directly

you need a public function to refer to the public variable

Code:
function ReadMasonicOrder as long
ReadMasonicOrder = masonicorder
end function

NOW, in your query you use the function in this syntax

Code:
[B]ReadMasonicOrder()[/B]



NOTE:


not [masonicorder] or even [readmasonicorder]
AND also with the brackets, otherwise you get "readmasonicorder", which is wrong again!


-----
just one other thing

you cannot use this directly
Public MasonicOrder as integer MasonicOrder=1

you have to do this
Public MasonicOrder as integer

and then in a sub, somewhere do
MasonicOrder=1 'or whatever value you require

you can only declare an explicit value as a const

Public const MasonicOrder = 1

but then you cannot change it, and you STILL need the function to use it in a query.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom