Solved

How to update a form field from a subform field

Posted on 2012-04-13
7
293 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
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…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

770 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