Reference Subform Recordest From Module Function

tembenite

Registered User.
Local time
Yesterday, 21:23
Joined
Feb 10, 2005
Messages
38
I'm trying to use the below code for several forms to reference the data on the forms subform. However, it doesn't seem to like
Set rst = ctl.RecordsetClone
I'm sure it has something to do with the syntax. How should I be referencing this data? Thanks!
----------------------------------------------
Function Example()
Dim rst As Object
Dim ctl As Control
For Each ctl In Screen.ActiveForm.Controls
If ctl.ControlType = acSubform Then
Set rst = ctl.RecordsetClone
Exit For
End If
Next ctl
If rst.BOF And rst.EOF Then Exit Function
rst.MoveFirst
Do Until rst.EOF
DO STUFF REFERENCING RST
LOOP
End Function
 
Got my own solution:
I needed to replace the for loop with below
Code:
For Each ctl In Screen.ActiveForm.Controls
        If ctl.ControlType = acSubform Then
            Set rst = ctl.Form.RecordsetClone
            Exit For
        End If
Next ctl
 

Users who are viewing this thread

Back
Top Bottom