Solved

Set a textbox in a form the same as another

Posted on 2013-10-30
9
465 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 total points
Comment Utility
you can do this
Forms!FormaA.textbox1 = Forms!FormB.textbox2
or

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

Author Comment

by:damixa
Comment Utility
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
Comment Utility
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
 

Author Comment

by:damixa
Comment Utility
So do I do this as a macro? what kind of action do I choose?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
<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
Comment Utility
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
Comment Utility
<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
Comment Utility
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
Comment Utility
Thanks Guys!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now