Solved

How to update a form field from a subform field

Posted on 2012-04-13
7
290 Views
Last Modified: 2012-05-01
I have a form that contains a job supervisor's name field.  The subform has the many supervisors that could be the actual job supervisor.  I want the form's supervisor field to be populated by the correct supervisor based on the user scrolling through the subforms' content .  When they find the correct supervisor, I want the user to hit a button on either the form or subform (whichever you think is best) to update the form's job supervisor's name with the correct supervisor's name from the subform.  Please help me determine how to make this work.  Thank you.
0
Comment
Question by:PJ_KD
  • 3
  • 2
7 Comments
 
LVL 21
ID: 37842841
I would recommend using a combo box to select the supervisor instead of a sub form.   It is also much easy to implement.
0
 

Author Comment

by:PJ_KD
ID: 37843006
Could the combo box be based on content from the other record?  (There is a JO record that is the source of the main form and the Contact record is the basis of the subform.)  If so, how would that be done?  Also, there are three fields involved which are the first and last name for the supervisor and the supervisor's email address.
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 400 total points
ID: 37853098
PJ,

I would agree with HiTechCoach, that the simplest way would be to use a combo box on the main form, but without actually seeing an example of your setup, I'm not sure how to answer your question:

"Could the combobox be basedon the content from the other record?"

If you put a button (cmd_Select) in the footer of your subform, then you could use code similar to the following:

Private Sub cmd_Select_Click

    me.parent.txt_SupervisorName = me.txt_SupervisorName

End Sub

Although I personally prefer to store the EmployeeID in the SupervisorID column.

HTH
Dale
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Assisted Solution

by:PJ_KD
PJ_KD earned 0 total points
ID: 37853333
I think that this may have solved my problem.  I put the button in the footer if the subform as you recommended.  
I received an error with the above Sub but did a slight change to:

Private Sub cmd_Select_Click

     Forms![main form name]![txt_SupervisorName] = Me.txt_SupervisorName

End Sub

I need to test it a little more tomorrow and will award appropriate points at that time.  Thank you for the assistance.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37855375
Yes, that should work as well. The syntax:

me.parent.controlname = xxx

should work, what error are you getting.
0
 

Author Closing Comment

by:PJ_KD
ID: 37913916
I appreciate the help.  I didn't get a chance to go back and see the error message generated by the original recoemmended solution but that hit allowed me to work through to a solution that I have now implemented in my database.  Much appeciated..
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

16 Experts available now in Live!

Get 1:1 Help Now