Save textbox value to a variable

  • Thread starter Thread starter Brandon Coates via AccessMonster.com
  • Start date 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?
 
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?
 
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?
 
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?
 
Back
Top