[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Update Access field from a button on a second form

Posted on 2012-03-21
12
Medium Priority
?
268 Views
Last Modified: 2012-03-26
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.
0
Comment
Question by:Elroy Taulton
[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
12 Comments
 
LVL 16

Expert Comment

by:DcpKing
ID: 37749063
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.
0
 

Author Comment

by:Elroy Taulton
ID: 37749094
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.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37749537
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:
me.YourControl=Forms!Form1!txtUserName

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


Jeffcoachman
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Expert Comment

by:IrogSinta
ID: 37749633
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
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37749706
IrogSinta,

LOL
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...

;-)

Jeff
0
 

Author Comment

by:Elroy Taulton
ID: 37753539
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.
ScreenHunter-02-Mar.-22-11.29.gif
ScreenHunter-03-Mar.-22-11.29.gif
0
 

Author Comment

by:Elroy Taulton
ID: 37753636
Sorry, included another screen shot showing the above syntax.
ScreenHunter-04-Mar.-22-11.49.gif
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 37753987
Where are you getting that syntax from?

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

Or

Forms![SomeFormName]![SomeOtherControlName]=SomeControlOnTheCurrentForm

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

JeffCoachman
0
 

Author Comment

by:Elroy Taulton
ID: 37754243
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

Correct?

If Matrix Form Entry = [SomeFormName] and
If Approver1=[SomeOtherControlName] and
If USR_NAME=[SomeControlOnTheCurrentForm]
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37754381
Correct, but again, it is still not clear which "Direction" this is being done from, so you may have to reverse the syntax...
0
 

Author Closing Comment

by:Elroy Taulton
ID: 37767383
Worked once I used the brackets.  Guess I figured I did not need the actual brackets.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37767974
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:
http://www.xoc.net/standards/rvbanc.asp
or:
http://en.wikipedia.org/wiki/Leszynski_naming_convention

;-)

JeffCoachman
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

656 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