text field to variable

J

James C.

I have a form that asks the user to input their name,manager,territoy. This
is done by text fields. I then have a button that calls a function (ie.
Main().

What I want to happen
I want the user to input the information in the 3 text fields, then when
they push the OK button, it takes the their information and associates it
with some variables so that I can use it in my public function, main().

Right now in the properties of the text fields I have the names set to
txtName
txtManager
txtTerritory

However, I have them as Unbound (which is where I am thinking my mistake
might be)

Any ideas?
 
A

AlCamp

Your Function Main() just has to set those variables...
Dim varName as String, varManager as String, varTerritory as String
varName = Me.txtName
varManager = Me.txtManager
varTerritory = Me.txtTerritory
hth
Al Camp
 
J

James C.

Thanks!!!

AlCamp said:
Your Function Main() just has to set those variables...
Dim varName as String, varManager as String, varTerritory as String
varName = Me.txtName
varManager = Me.txtManager
varTerritory = Me.txtTerritory
hth
Al Camp
 
J

James C.

I am still having some problems, Access gives me an error

Invalid use of keyword Me!

Any ideas
 
A

AlCamp

The Me.txtName refers to fields on your form where the Name value is
entered. I take it you have a form where these values are entered, and then
you run a function in that form's module that uses those values as variable
in further operations.
If this next suggestion doesn't work... send more detail of what you've
setup, (form? fieldnames? Event Procedure code? ..etc.)

Try this instead...
varName = [txtName]
varManager = [txtManager]
varTerritory = [txtTerritory]

hth
Al Camp
 
A

AlCamp

James,
On further thought, please try this also...
varName = Forms!frmYourFormName.txtName
varManager = Forms!frmYourFormName.txtManager
varTerritory = Forms!frmYourFormName.txtTerritory
hth
Al Camp
 

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