Save textbox value to a variable

  • Thread starter Brandon Coates via AccessMonster.com
  • Start date
B

Brandon Coates via AccessMonster.com

I want to save what is in a textbox on a form into a variable so it can be placed into a different textbox on another form when the button is clicked. Are there any other ways to get this value from one form to another?
 
P

PC Datasheet

Put this expression in a standard module:
Public MyVariable As String '(or As Integer, or As Long depending on the
datatype of what's in the textbox)

On Form1:
MyVariable = Me!NameOfTextbox1

On Form2:
Me!NameOfTextbox2 = MyVariable

OR ----------

If Form1 is open at the same time Form2 is open, skip all of the above and
put the following in the Open event of Form2:
Me!Textbox2 = Forms!Form1!Textbox1

Note - Form1 can be not visible and this will still work.


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Brandon Coates via AccessMonster.com said:
I want to save what is in a textbox on a form into a variable so it can be
placed into a different textbox on another form when the button is clicked.
Are there any other ways to get this value from one form to another?
 
B

Brandon Coates via AccessMonster.com

What if Multiple forms open the other form is there a way to generalize it? My table Employee opens three other tables how do I do as you stated above in the other tables?
 
P

PC Datasheet

Use this to open Form2:
DoCmd.OpenForm "Form2",,,,,Me!NameOfTextBox

Put this in the Open event of Form2:
Me!NameOfTextbox = Me.OpenArgs

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Brandon Coates via AccessMonster.com said:
What if Multiple forms open the other form is there a way to generalize
it? My table Employee opens three other tables how do I do as you stated
above in the other tables?
 

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