Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to update a form field from a subform field

Posted on 2012-04-13
7
Medium Priority
?
309 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 49

Accepted Solution

by:
Dale Fye earned 1200 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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 49

Expert Comment

by:Dale Fye
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
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: …

885 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