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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enumerating Controls on Closed Forms 2

Status
Not open for further replies.

jmeadows7

IS-IT--Management
Joined
Jun 13, 2001
Messages
148
Location
US
I've read through thread 705-622652, but I have yet to figure out how to enumerate through the controls on a form that is currently closed.

I want to create a list of controls on any form I select in the database. I know someone here must have the answer to this question!

Thanks,
 
You will have to open the form in order to walk through the controls collection for that form. You can use code similar to the following to accomplish that task
Code:
Dim TheObj              As AccessObject
Dim TheForm             As Form
Dim TheCntrl            As Control
Dim lBol_ForceOpen      As Boolean

For Each TheObj In Application.CurrentProject.AllForms
   lBol_ForceOpen = Not TheObj.IsLoaded
   If (lBol_ForceOpen = True) Then
      DoCmd.OpenForm TheObj.Name, acDesign, vbNullString, vbNullString, acFormReadOnly, acHidden
   End If
   Set TheForm = Application.Forms(TheObj.Name)
   For Each TheCntrl In TheForm.Controls
      <do what you need to do with the control(s)>
   Next
   If (lBol_ForceOpen = True) Then
      DoCmd.Close acForm, TheObj.Name, acSaveNo
   End If
Next TheObj

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Hey Cajun,

Thanks for confirming what I thought might be true and for providing the couple of lines I needed without having to dink around with it.

For replying and being completely correct - have a star!

Thanks,
Jimmy
[thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top