Solved

Access Form design

Posted on 2011-09-09
5
183 Views
Last Modified: 2012-05-12
This is really 2 questions, but same issue that I dont even know if its possible.

Is it possible using VBA to list all the forms in an Access database, then look at each element on that form, and read the values of that controls position on the form.

Im trying to document one of our database's and I can already easily do the tables and queries, but Im stuck on the forms, and would really like to creat a report which just lists all the text boxes, combos buttons etc and their positions on the page.

Thanks in advance for any help.
0
Comment
Question by:tonelm54
5 Comments
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 167 total points
Comment Utility
For each frm in currentproject.allforms
    For each ctrl in frm.controls
        debug.print ctrl.Name, ctrl.left, ctrl.Top, ctrl.width, ctrl.height
    Next ctrl
Next frm
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
<Is it possible using VBA to list all the forms in an Access database, then look at each element on that form, and read the values of that controls position on the form.
>  the Answer is YES

but, before we go there,

have you tried using the Documenter ?

Tools > Analyze  > Documenter
0
 
LVL 38

Assisted Solution

by:Aaron Tomosky
Aaron Tomosky earned 167 total points
Comment Utility
Here is an example of someone using vba to open a form, loop through all controls, and save some properties to a table. If you modify this to grab the properties you want it should work
http://www.access-programmers.co.uk/forums/showthread.php?t=125730
0
 
LVL 33

Expert Comment

by:Norie
Comment Utility
Here's some very crude code.
Option Compare Database
Option Explicit

Sub DocumentForms()
Dim frm
Dim ctl As Control

    For Each frm In CurrentProject.AllForms
      DoCmd.OpenForm frm.Name, acDesign
      
        Debug.Print frm.Name
        
        For Each ctl In Forms(frm.Name).Controls
            Debug.Print Space(10) & ctl.Name & ":" & TypeName(ctl)
            Debug.Print Space(15) & "Top:     " & ctl.Top
            Debug.Print Space(15) & "Left:     " & ctl.Left
            Debug.Print Space(15) & "Height:  " & ctl.Height
            Debug.Print Space(15) & "Width:   " & ctl.Width
        Next ctl
        
        DoCmd.Close acForm, frm.Name
        
    Next frm
End Sub

Open in new window

0
 
LVL 26

Accepted Solution

by:
Nick67 earned 166 total points
Comment Utility
If you want to go with complete overkill, you can use the undocumented SaveAsText
SaveAsText acForm, "Form1", "C:\temp\Form1.txt"
You'll get a txt file with a boatload more detail than you'll ever want
The undocumented LoadFromText will pull these textfiles back into a database
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now