Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Form Control count for ALL CLOSED forms

Status
Not open for further replies.

rproactive

Technical User
Oct 6, 2005
65
US
Hello all. I have struggled with this simple problem for several days & could sure use some advise pointing me in the right direction.

Is it possible to find count of controls (Forms(n).Controls.Count) on ALL forms that are closed?
Following code prints all closed forms property name & values. It works fine for open forms (code not shown) but not for closed forms.
Code:
'CLOSE forms, count of controls in each open form, the propertiies name & values for each control.
nn8 = 0
For Each obj8 In dbs8.AllForms
mm8 = 0
  If obj8.IsLoaded = False Then 
    Debug.Print "CLOSE Form (" & nn8 & "): " & obj8.Name &_
    "count of controls=  " & [b]Forms(nn8).Controls.Count[/b]
                 
1020: 
    If Forms(nn8).Controls.Count - mm8 > 0 Then
      Debug.Print  name of property (0): “ &  Forms   
      (nn8).Controls(mm8).Properties(0).Name & _
      "Value: " & Forms(nn8).Controls(mm8).Properties  
      (0).Value
               
      mm8 = mm8 + 1
      GoTo 1020
    End If
    nn8 = nn8 + 1
 End If
        
1029:
Next obj8
    
1030:
Exit Sub
I get Runtime error 2456. THe number you used to refer to the form is invalid.
Forms(nn8).Controls.Count

Can I Open all forms in code determine count & then close?? How would I do this- or is there some other way?

Help greatly appreciated.
 
You may use the acHidden parameter with the DoCmd.openForm method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top