Solved

Set a textbox in a form the same as another

Posted on 2013-10-30
9
477 Views
Last Modified: 2013-10-30
I have a quick problem. I need a macro or code that will set a textbox in form A the same as Form B

so something like this

Set FormaA.textbox1 = FormB.textbox2

thanks in advance
0
Comment
Question by:damixa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 250 total points
ID: 39612136
you can do this
Forms!FormaA.textbox1 = Forms!FormB.textbox2
or

Forms!FormaA!textbox1 = Forms!FormB!textbox2
0
 

Author Comment

by:damixa
ID: 39612149
I need to have a button that updates textbox1 = textbox2

once I am on form containing textbox2, I need to be able to change this if I need to without changing textbox1

so just a Set button that updates the values
0
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
ID: 39612156
You can also use the Me prefix if the code is on the same form as one of the boxes

Me.text = forms!formb.text2
0
Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

 

Author Comment

by:damixa
ID: 39612169
So do I do this as a macro? what kind of action do I choose?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39612182
<I need to have a button that updates textbox1 = textbox2>

place the codes in the click event of the button

private sub btnName_Click()

Forms!FormaA.textbox1 = Forms!FormB.textbox2


end sub
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39612354
And just to be clear, ...
Why is this needed?
How is the data in the two form related?

I only ask because this is a very rare request, so perhaps there may be a alternate approach to doing this...

I am just curious really

JeffCoachman
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39612393
<So do I do this as a macro? what kind of action do I choose?>

What we are describing is VBA (Visual Basic for Applications) not macros, which is how the regulars here generally respond -  most of us prefer VBA over macros for a variety of reasons.

The way you would enter this type of code is - for a command button, in design view -  right click the button, then select "Build Event", then "Code Builder" and enter the code in between the Sub and End Sub lines when the VBA editor opens.

This also can be done with macros if you want ... the Action you are looking for is SetProperty, and you would set the Value property.  The resulting macro might look something like this:

SetProperty...Value
But I'd suggest VBA over macros in the long run, for easier debugging, greater versatility, etc...
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 39612579
When I first read your question, I thought you wanted to create another textbox the same as the first, but I think you are referring to the value in the textbox, which is quite a different matter.

If Form B is to have the same value in a textbox as in a textbox on Form A, often their data sources are related.  Is that so?  Is Form B opened from Form A?  In that case, you could set the value of the textbox on Form B from a button that opens Form B, or Form B's Load event.  We need more information here.  You may not need to set the value of the textbox on Form B at all, if the relationships are set up correctly.
0
 

Author Closing Comment

by:damixa
ID: 39612730
Thanks Guys!
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month8 days, 5 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question