Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How and where can I declare Public Constants at start up 1

Status
Not open for further replies.

rw22392

Technical User
Joined
Jul 7, 2002
Messages
5
Location
CA
How and where can I declare Public constants at start up and use it as a parameter in a query.
The reason I want to do this is to get the user signed on information and based on that asign a constant to them. Then when I carry out different actions in different places I want to use the constant as the criteria to run several different query's. or select different forms Etc.

Anyone have any ideas
Thanks In advance Bob
 
I don't belive you can assign a constant at runtime (startup). Once a constant is assigned, you can't change it. And, I also don't belive that a query can reference a variable (public or otherwise).

However, you can set up a public variable and set it to what you want. Then create the query on the fly. Or, put a field on your form and put the information you want in that field(s) and then reference the field from your query.

 
I think what you are asking for is a Public variable, which can be declared in the Standard Module. A query can reference a Function so return the public variable to the query with a function.

In standard module.
Public myvar string

Function returnmyvar() as string
returnmyvar = myvar
End function

In code some place.
dim sql as string
sql = "Select * from mytable where akey = " & _
"'" & returnmyvar() & "'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top