[AccessD] Walk the controls on a given form

Arthur Fuller artful at rogers.com
Mon Jul 11 19:32:55 CDT 2005


Works a treat. Thanks much!

Arthur

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of MartyConnelly
Sent: July 11, 2005 12:44 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Walk the controls on a given form

This works just pass form name and set form in subroutine

Sub ListRowDataSources(fname As String)
Dim ctl As Control
Dim f As Form
   'assume the form has already been opened by the calling process
   'I want to walk the controls
   'the only controls of interest are combos or listboxes so I can skip
   'over all others
   Set f = Forms(fname)
   Debug.Print f.Name
   For Each ctl In f.Controls
      'If the control is either a listbox or combo-box
      Select Case ctl.ControlType
      Case acComboBox, acListBox
         Debug.Print ctl.Name & ":" & ctl.RowSource
      Case Else
      End Select
   Next
set f=nothing
set ctl=nothing
End Sub





More information about the AccessD mailing list