Solved

Access Form design

Posted on 2011-09-09
5
188 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
ID: 36511380
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36511395
<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
ID: 36511409
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
ID: 36511578
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
ID: 36511605
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

773 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