Retrieving control information from a form


Question

Is it possible to retrieve control information from a form in an external MDB file?

Answer

From: Shamil Salakhetdinov <shamil@marta.darts.spb.ru>
To: ACCESS-L <ACCESS-L@PEACH.EASE.LSOFT.COM>
Subject: Re: Retrieving control information from a form
Date: 29 May 1999 2:07

Sam,

You can solve your task using Automation:

Dim app As Access.Application
Dim dbs As DAO.Database
Dim doc As DAO.Document
Dim frm As Access.Form
Dim ctl As Access.Control

Set app = New Access.Application
app.OpenCurrentDatabase (<YourDBPathHere>)
Set dbs = app.CurrentDb()

For Each doc In dbs.Containers("forms").Documents
    app.DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
    Set frm = app.Forms(doc.Name)
    For Each ctl In frm.Controls
     '...
    Next
    DoCmd.Close acForm, doc.Name, acSaveNo
Next
'....
app.Quit
Set app = Nothing
'...

The only problem is to bypass Autoexec macro activation when you use OpenCurrentDatabase(..)

HTH,
Shamil


HOME    TOPICS

Copyright © 1999 by Shamil Salakhetdinov.
All rights reserved. Terms of use.

Last updated: October 10, 2006

Published also here at 4TOPS: Retrieving control information from a form