i have a main form that is based on a query, with a subform that is also based on a query...how do i requery the subform when a value changes in the main form without requerying the main form?
You should be able to do it very easily. Go into your event handler code for when you want this to happen and paste the following code. (For example if you want to to requry after 'Text1' is updated. Right click on 'Text1'. Click the event tab. On the after update line type "[Event Procedure]". Click on the three dot button and paste your code between the private sub line and the end sub line) If your subform is named something other than child0 then replace child0 with the name of your subform
Code:
Child0.Requery
The hardest questions always have the easiest answers.
Write subform requery command in the procedure Form_AfterUpdate of main form. It will be excellent that user don't espy this action. You can write following codes in the procedure Form_AfterUpdate of main form:
Private Sub Form_AfterUpdate()
Dim varFieldID 'Variant type variable
Dim rst As Recordset
'Value of unique field of current record for bookmarking
varFieldID= Me.MySubForm.Form!FieldID 'Requery the subform
Me.MySubForm.Form.requery 'Find previouse subform's record (before requery)
rst.FindFirst "FileID=" & varFieldID 'Use necessary separators for different field types
If Not rst.NoMatch Then 'If found
Me.MySubForm.Form.Bookmark = rst.Bookmark
End If
rst.Close
Set rst = Nothing
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.