title: Microsoft Access - Loop through all forms and controls on each form
body: <p>Okay so when I press a specific button I want to loop through all forms, then find every control in each form with the tag 'TESTING'. If the tag = 'TESTING' then I want to change the caption of the object to 'abc123'.</p>
  
  <p>The only objects with the tag 'TESTING' will be labels, so they will have the caption property.</p>
  
  <p>So far I have this as the function:</p>
  
  <pre><code>Public Function changelabel()
  
  On Error Resume Next
  Dim obj As AccessObject, dbs As Object
  Dim ctrl as Control
  
  Set dbs = Application.CurrentProject
  
  For Each obj In dbs.AllForms
  DoCmd.OpenForm obj.Name, acDesign
      For Each ctrl In Me.Controls
          If ctrl.Tag = "TESTING" Then
          ctrl.Caption = "abc123"
          End If
  
          Next ctrl
  
  Next obj
  
  End Function
  </code></pre>
  
  <p>Then this as the button code:</p>
  
  <pre><code>Public Sub TestButton_Click()
  Call changelabel
  End Sub
  </code></pre>
  
  <p>So it executes the first for loop and opens all the forms in design view correctly. The problem lies with the second for loop. None of the label captions that have the tag property as 'TESTING' are changed to 'abc123'.</p>
  
  <p>So what do I need to change to get the second for loop to work?</p>