Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Data in Subform? 1

Status
Not open for further replies.

LindaLou

Technical User
Feb 3, 2001
16
0
0
US
Hi All,

I have a main form which is tied to the subform by employee ID. Main form is used to enter schedule variances for the employee. The subform displays the employee position and shift info from the employee detail table. Problem is when I enter the employee ID in the main form, the subform will not populate with data until I close and reopen the main form. How can I get the subform to update and be viewable as soon as the main form is populated with the employee ID? I assume I have to set an event procedure but don't know what to enter. Any help appreciated!
 
Yes you need a trigger (Event Procedure)
Do you have a "save" button?
Or you can put it in the last fields After_update event.

'save the record on the main form
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

' Requery the sub form
Me![Yoursubform].Requery






DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
You could try something like this:

Private Sub ControlName_Event()
DoCmd.Requery Me!
End Sub

ControlName = name of control
_Event = trigger event -- you'd have to determine the best trigger: lost focus, get focus, click, or whatever.
 
Ok, here is what I did based on the suggestions from both of you. I did not want to create a save button since additional data must be entered on the main form after viewing the subform data. What I did was attach the following to the "On Click" property of the LastName field which then brings up the subform data tied to the employee ID.

Private Sub LName_Click()

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord,,acMenu Ver 70

Me![frmAssocDetInfo].Requery
End Sub

This seems to be working perfectly! Upon clicking the LastName field and selecting from the dropdown menu, the subform is autopopulated with detail info for that employee. The tab order then changes focus from the LastName field to the next data entry field on the main form. If anyone sees a problem with doing it this way, please let me know, but seems to be working fine. Thanks for the help, both of you!

Linda

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top