Refresh All Combo Boxes (1 Viewer)

speakers_86

Registered User.
Local time
Today, 11:31
Joined
May 17, 2007
Messages
1,919
This routine can be run in a form's after update event. It scans all open forms, and one subform for combo boxes and refreshes them. It can be expanded to refresh other control types or more subforms, but I don't have the need, so have at it!


Code:
Public Sub RefreshCombos()
    Dim frm    As Form
    Dim ctl    As Access.control
    Dim ctl2 As Access.control

    For Each frm In Application.Forms
        If CurrentProject.AllForms(frm.Name).IsLoaded Then
            For Each ctl In frm
                If ctl.ControlType = acComboBox Then
                    ctl.Requery
                Else
                    If ctl.ControlType = acSubform Then
                        For Each ctl2 In ctl.Form
                            If ctl2.ControlType = acComboBox Then ctl2.Requery
                        Next
                    End If
                End If
            Next ctl
        End If
    Next frm
End Sub
 

Mihail

Registered User.
Local time
Today, 17:31
Joined
Jan 22, 2011
Messages
2,373
Hi Speackers !

May I ask you something, please ?
It is about this line:
Code:
If ctl.ControlType = acSubform Then ...
A form that is used as subform is not in founded here (as a loaded form) ?
Code:
 If CurrentProject.AllForms(frm.Name).IsLoaded Then ...
Thank you.
 

Users who are viewing this thread

Top Bottom