Solved

Set a textbox in a form the same as another

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

Author Comment

by:damixa
ID: 39612169
So do I do this as a macro? what kind of action do I choose?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 119

Expert Comment

by:Rey Obrero
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

895 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

14 Experts available now in Live!

Get 1:1 Help Now