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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public variables

Status
Not open for further replies.

stonewal

Technical User
Sep 26, 2000
17
0
0
US
I have declared a public variable CurrentName in a class module named PubVars. I thought I could use this variable anywhere such as a criteria in a filter or a query but all I get is an "enter parameter value" common dialog box. I am referencing my public variable
[PubVars].[CurrentName]

I am really stumped. Any suggestions? Thanks!
 
Hi,
As far as I know; you can't referrence a variable from any place other than a module. Public simply means that multiple procedures can Access that same variable. The only way you can get a query to acknowledge a variable is to embed the SQL statement into the module code, then use the "&" to place it into the query. ie. "SELECT * FROM Clients WHERE Name = '" & MyName & "'". You can set the query parameter to point to a control on a form that will be open at the time the query is ran. You would referrence this with the Forms collection. Forms![MyForm].[MyTextBox]
Rob Marriott
CCTC1
rob@career-connections.net
[sig][/sig]
 
Heya,

I have a look through the Q&As of previous posts and since I am only a beginner with VBA, not much of it made much sense.

The problem I have is that I want a module to look at a text box on a form (to see what the value is) and depending on the value of the number inside the text box, do a certain calculation.

Now I have wrote the Select... Case statements using VB knowledge to work out the number boundries and it works, but the only problem is I don't know how to get the number inside the textbox to be set as a variable within my module.

Can anyone help?

Tom Griffiths
tom@vscan.org
 
Sorry ladies and gentlemen, I filled in the wrong box :(

*Goes back to bed*

Tom Griffiths
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top