how do I open all forms, and going through all controls?

smig

Registered User.
Local time
Today, 05:49
Joined
Nov 25, 2009
Messages
2,209
What I want is to open all forms, one by one, and going through all controls to edit The .OnMouseMove event
How can it be done ?

I tried to use this piece of code:
Code:
Dim frmObj As AccessObject
Dim ctl as Control
 
For Each frmObj In Application.CurrentProject.AllForms
    DoCmd.OpenForm frmObj.name, acDesign
This work but I can't find the way to go through controls as what I get is AccessObject and not a Form object, and can't use this part of the code:
Code:
    For Each ctl In frmObj.name
        With ctl
           ....
        End With
    Next ctl
 
I use a function like this to iterate through all controls on a specific form:
Code:
Public Function SetStatusOfControls(FormName As String)
      'define a variable for the controls collection in the form
      Dim ctl As Control
      'iterate through each control on the form
      For Each ctl In Forms(FormName).Controls
             'code to do something with each control goes here
      Next ctl

Hopefully you can modify this code to do what you want.
 
Thank you

this is what I missed:
Forms(FormName).Controls
 

Users who are viewing this thread

Back
Top Bottom