Update a subform's recordsource in an Access database
Overview:
If you have an Access form with a subform, and you want to use VBA code to update the recordsource of the subform as soon as data in the main form changes, use the following VBA code:
Dim strsubform As String
strsubform = "SELECT * from a table"
forms!frmMainForm!frmSubform.Form.RecordSource = strsubform
This code is typically run whenever data is changed in the main form. So, if your main Access form allows the user to select a record from a combo box, then this code would run when the combo box is changed (in the after update event).