Solved

How to update a form field from a subform field

Posted on 2012-04-13
7
296 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
[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
  • 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
Independent Software Vendors: 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!

 

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

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!

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

761 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