Question : Requery a listbox

There are several listboxes on a tab control.  I would like to be able to requery through all the listboxes without regard to the name of the listbox.  This way, if there are new listboxes added to the form, they will be requeried at the same time.

sub requeryAll()

Me.txt_A.Requery
Me.txt_B.Requery
Me.txt_C.Requery
Me.txt_D.Requery
Me.txt_E.Requery
Me.txt_F.Requery
Me.txt_G.Requery
Me.txt_H.Requery
Me.txt_I.Requery
Me.txt_J.Requery
Me.txt_K.Requery
Me.txt_L.Requery
Me.txt_M.Requery
Me.txt_N.Requery
Me.txt_O.Requery
Me.txt_P.Requery

end sub

Thanks

Paul

Answer : Requery a listbox

sub requeryAll()

Dim ctl As Control
For Each ctl In Me.Controls
    Select Case ctl.ControlType
        Case acListBox

                Me(ctl.Name).Requery

    End Select
Next

End Sub
Random Solutions  
 
programming4us programming4us