How do I requery one subform after an item is clicked in another subform?

scooteman

Registered User.
Local time
Today, 14:10
Joined
Nov 30, 2009
Messages
57
I have a form that has two subforms. One subform shows the required training that an employee should have based on his job classification. The second form shows what training is currently assinged for that employee. I have it setup so that a user can click on any item in the first list that is missing from the employee and have it added to his records.

I would like the subform showing what the employee currently has assigned to be updated after each item is clicked on the first subform. The vb code for on click event is:

Private Sub Training_Name_Click()
Dim trainmsg As Integer
trainmsg = MsgBox("Are you sure you want to add this training type to the selected employee?", 1, "Training Addition Message")
If trainmsg = 1 Then
DoCmd.SetWarnings warningsOff
DoCmd.OpenQuery "Query_Append_unassignedtraining"
DoCmd.SetWarnings warningsOn
End If
End Sub

How do I requery my other subform? What would be the correct coding to add after warningsOn?

Thanks.
 
I will assume that this code in in the sub form.

Try:
Code:
Me.Parent.[SUbFormName].form.requery

Replace [SUbFormName] with the actual name of the other sub form control's name.
 
I found the answer on the web. I used the below in my vb code and it worked:

Forms![MainFormName]![SubformControlName].Requery
 
Sounds like you want to link the subform to the main form (or parent form). Set the Control Source property of the subform to the name of the main form. Then set the Link Master and Link Child Fields to the two fields that should link both. Master being the parent and Child being the subform
 

Users who are viewing this thread

Back
Top Bottom