Solved

Set a textbox in a form the same as another

Posted on 2013-10-30
9
469 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
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

785 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