Update Access field from a button on a second form

I have two forms.  In one form, I am pulling Full names and users names.  The other form is used for data entry.  I want to see if I can (after data is retrieved on form 1) add a button on form one that will take the username and populate it in one of the text fields on form 2.  

Trying to make this easy for my end users.

As a note, both of my tables are ODBC SQL tables.  This should not matter but wanted to be sure it was stated.
Elroy TaultonDevelopment ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Open the second form and then tell it to requery with the user name.  Something like this
docmd.openForm B
form_B.filter="UserName='" & me.txtUserName & "'" '

You could also have a method on form B that sets it to show the details for a particular user that it gets from a parameter, and invoke that method with the selected username from the code in the button on Form A. IMHO that's the cleanest, best, and most elegant technique.
Elroy TaultonDevelopment ManagerAuthor Commented:
The original form would already be open.  It is an entry form, however the user will have to lookup some values that they would not know.  The second form allows them to search for this info.  

Instead of me depending on them to type the data correctly, I want the button to auto-populate the field on the entry form.  Does this make sense?

Not sure your solution will work for this.
Jeffrey CoachmanMIS LiasonCommented:
The way you phrased your question originally, DcpKing's solution should work.
Remember he stated: "Something like this"

So on the button on the "second" form, try something like this:

Just note that you did not post any details on the design of these forms, so guesses is all we can provide...

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

boag200's answer will work if your button is on your 2nd form.  I believe you mentioned that you wanted the button on form 1 so you would modify boag200's answer as follows:

Sub button1_click()
     Forms!NameOfForm1!txtUserName = me.YourControl
End sub

Or if you decide to have your form2 as a subform of form1, you would use this:

Sub button1_click()
     me.NameOfsubform.form!txtUserName = me.YourControl
End sub
Jeffrey CoachmanMIS LiasonCommented:

Yeah, I was a bit confused to as to where this "button" was to...

No sweat here, ...if your syntax is what they wanted, I don't need any points...


Elroy TaultonDevelopment ManagerAuthor Commented:
So, now I am getting an error message from the code.  I am attaching screen prints that should help.  I have two independent forms.  One is an entry and the other is used for data lookup to fill in the entry.

Following the above suggestions, I am receiving the following error: Invalid use of property.  Thoughts?

Please ask question if I am unclear.
Elroy TaultonDevelopment ManagerAuthor Commented:
Sorry, included another screen shot showing the above syntax.
Jeffrey CoachmanMIS LiasonCommented:
Where are you getting that syntax from?

The correct syntax should be something like this:
SomeControlOnTheCurrentForm=Forms![Some Other Form Name]![Some Control Name]



This is why it is always best to simply post a sample of the DB...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Elroy TaultonDevelopment ManagerAuthor Commented:
Right, understand.  Let me try that.  There are limitations (from an employer point of view) about what I can post and not.  Trust me, if I could I would have first thing.

So my syntax would be:

Forms!'Matrix Form Entry'!Approver1=USR_NAME


If Matrix Form Entry = [SomeFormName] and
If Approver1=[SomeOtherControlName] and
If USR_NAME=[SomeControlOnTheCurrentForm]
Jeffrey CoachmanMIS LiasonCommented:
Correct, but again, it is still not clear which "Direction" this is being done from, so you may have to reverse the syntax...
Elroy TaultonDevelopment ManagerAuthor Commented:
Worked once I used the brackets.  Guess I figured I did not need the actual brackets.
Jeffrey CoachmanMIS LiasonCommented:
The brackets should only be needed if you have spaces in your object names...

This is why spaces in object names is frowned upon.

Try to adopt a standard Naming convention like:


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.