customizing "documentor" output

W

W Garrard

Hi All,
I have to document an inherited set of MSAccess 2000 files and it would be
very helpful if I could customize the output from the tables documentor. I
would like to have the table report output include the "field description"
(info visible in table design view) and the "caption" in addition to the
default info (e.g., field name, data type, and data size).

I assume the only way to do this is using VBA. I am pretty good at
modifying existing VBA code if someone can point me to a relevant example
for this. Of course, I would love a nonVBA option for doing this. Can
anyone point me to a solution?

Also, it would be worth upgrading to a newer version of MSAccess if the
documentor output was customizable. Anyone know this?

Thanks in advance,
wg
 
J

Jeff Conrad

You can use the following two functions placed in any
standard module to return a list of each field's
Description and Caption properties.

' Code Start
Public Function funcListTableFieldDescription()
On Error GoTo ErrorPoint

' Prints Description of each table
' field to Immediate Window for
' specified table
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As Field

Set db = CurrentDb
Set tdf = db.TableDefs("YourTableNameHere")
For Each fld In tdf.Fields
Debug.Print fld.Properties("Description")
Next fld

ExitPoint:
db.Close
Set db = Nothing
Exit Function

ErrorPoint:
If Err.Number = 3270 Then
Resume Next
Else
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " _
& Err.Description _
, vbExclamation, "Unexpected Error"
End If
Resume ExitPoint

End Function

Public Function funcListTableFieldCaption()
On Error GoTo ErrorPoint

' Prints Caption of each table
' field to Immediate Window for
' specified table
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As Field

Set db = CurrentDb
Set tdf = db.TableDefs("YourTableNameHere")
For Each fld In tdf.Fields
Debug.Print fld.Properties("Caption")
Next fld

ExitPoint:
db.Close
Set db = Nothing
Exit Function

ErrorPoint:
If Err.Number = 3270 Then
Resume Next
Else
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " _
& Err.Description _
, vbExclamation, "Unexpected Error"
End If
Resume ExitPoint

End Function
' Code End

In addition to these functions you may want to use a nice
utility written by MVP John Viescas.

On one nice slick report it prints exactly what you're
after (except the Caption property) in a very easy to read
format.

Go here:
http://www.viescas.com/Info/links.htm

Download one of the sample files near the bottom.
I'm not sure if the utility is in every download or not.
Try the wedding one to be sure.

1. Import the following things to your database:
Table: zTableFields
Report: zTableFields
Module: zmodDumpTbl

2. Compile your database immediately.

3. Delete all the records in that table.

4. Open the module in Design View and then go to the
Immediate Window (CTRL G). Type DumpTables and hit Enter.
The table will now be populated with all your field
properties from all tables!

5. Now just open the report! Poof! Instant slick report!
Very nice.

Anytime you make changes to any fields and want to see an
updated report just delete all the records in the table
and run the module code again. I took it one step further
and made a command button on a form to open the report.
The code first deletes all the records in the
zTableFields, then runs the module code, then opens up the
report. Way cool. I use this in all my databases now.

Incidentally, in about five minutes I was able to modify
the table, report, and module to include the caption
property which is exactly what you're after. If you need
help with this just post back and I'll provide further
instruction.

Hope that helps,
 
D

Duane Hookom

After you run the documenter, you can create a link to the table that
contains all the property values. The table connection on my PC is
DATABASE=C:\Documents and Settings\Duane Hookom\Application
Data\Microsoft\Access\ACWZUSRT.MDT;TABLE=doc_tblObjects
You can then create a crosstab with SQL like:

TRANSFORM First(doc_tblObjects_2.Extra1) AS FirstOfExtra1
SELECT doc_tblObjects.Name AS TableName, doc_tblObjects_1.Name AS FieldName,
doc_tblObjects_1.Extra2 AS FieldType, doc_tblObjects_1.Extra3 AS FieldSize
FROM doc_tblObjects AS doc_tblObjects_2 INNER JOIN (doc_tblObjects AS
doc_tblObjects_1 INNER JOIN doc_tblObjects ON doc_tblObjects_1.ParentID =
doc_tblObjects.ID) ON doc_tblObjects_2.ParentID = doc_tblObjects_1.ID
WHERE (((doc_tblObjects_1.TypeID)=11))
GROUP BY doc_tblObjects.Name, doc_tblObjects_1.Name,
doc_tblObjects_1.Extra2, doc_tblObjects_1.Extra3
PIVOT doc_tblObjects_2.Name In ("Caption:","Description:");
 
J

Jeff Conrad

How in the world do you come up with this stuff Duane??!
That is VERY slick!
Is there some documentation on this somewhere you found?
 
D

Duane Hookom

Hi Jeff,
I found this quite a while ago but don't recall how. I knew there would be a
table created in an MDT file and just searched. You can open the MDT
directly and see lots of interesting stuff but none of it is documented and
if you mess up something, you may have wizards or builders BREAK.

Regarding the documenter, I have created a crosstab of field names as row
headings and table names as column headings and size a the value to see
where fields are common to various tables.
 
J

Jeff Conrad

Hi Duane,

I can understand why it is probably not documented anywhere; everything could get messed up just as
you say!

I did not even realize there were these MDT files in various profiles.

Incidentally, this must be something from Access 2000 onward.
I could only find one MDT file on a computer running Access 97 called Wzdat80.mdt.
That did not have this type of information you discussed.
I wonder if that information is stored somewhere else in Access 97??

Also, I found something interesting.
On a Access 2000 machine I had trouble actually linking to the MDT file.
When I browsed to the correct folder no MDT files showed up because it was not one of the listed
file types on the dialog box. I thought there would be an option for "All Files", but there was no
such option. With the correct folder showing I actually had to type in the name of the MDT before I
could link to it. Strange. Did you have the same issue?
 
D

Duane Hookom

The MDT file extensions don't show so I would find the folder and type in
*.mdt
to bring up the file name.
Prior to Access 2000, you were offered the ability to save the results of
documentor in a table.

I have used the results of the documenter to re-create forms on the fly from
scratch. The doc_tblObjects table can contain all the information required
to create your form on-the-fly. It wasn't easy but I needed this to run as
an MDE add-in to create a form with controls etc in a user's mdb file.
 
J

Jeff Conrad

Hi Duane,
The MDT file extensions don't show so I would find the folder and type in
*.mdt
to bring up the file name.
Prior to Access 2000, you were offered the ability to save the results of
documentor in a table.

I did not realize you could save the results to a table in Access 97!
I just tried that and sure enough it created a table called "Object Definitions."
Very interesting.
Learn something new every day here.
I wonder why they removed this feature from later versions.
I have used the results of the documentor to re-create forms on the fly from
scratch. The doc_tblObjects table can contain all the information required
to create your form on-the-fly. It wasn't easy but I needed this to run as
an MDE add-in to create a form with controls etc in a user's mdb file.

Now THAT is intriguing!
So using the information in doc_tblObjects you can re-create a form???
(Loaded question coming...) How?

Is this process something similar to how the Switchboard Manager creates the Switchboard form?
Is all the necessary information in a table and some code somewhere uses it to create all the form
objects?
Just curious.

I realize this is probably an extremely difficult thing to do so I'm not looking for a complete
walk-though by any means, I would just like to expand my knowledge on this. Is there some reference
material or documentation I can look at to study? I have the ADH 97 book. Is some of this covered in
there?

One last question if I may.
What "type" of form did you need to create in a user's mdb file?
I'm having difficulty grasping the how and why this would be needed.

Thanks again for all the info.
 
D

Duane Hookom

I hate the name "Object Definitions" and generally changed it to "ObjDef"
immediately after it saved.
The code to create the form is long gone since I worked for another company.
The code was used in the BR Code Stuffer
http://www.rogersaccesslibrary.com/...'BR Code Stuffer Add-In/Builder for Access 97'.
I distributed the Code Stuffer as an MDE. There is a utility in the Code
Stuffer that allows the user to easily create a MsgBox that is actually a
MenuBox with user provided options and captions. If the Code Stuffer wasn't
an MDE I think I could have copied a form from the Code Stuffer into the
developer's MDB. Because of the MDE, I had to use code to create the form
and add controls. There is a table in the wizard that contains the
properties required to build the form on the fly. This table was created by
using the documenter. You won't see the code to do this in the Code Stuffer
wizard because it is an MDE file.

There are several wizards in Access that create forms and reports.

If you use Access 97 and write code but don't use the Code Stuffer, you
should.
 
J

Jeff Conrad

Hi Duane,

Comments below...

I hate the name "Object Definitions" and generally
changed it to "ObjDef" immediately after it saved.

Understood. I was just playing with it for now.
The code to create the form is long gone since I worked
for another company.

Ah, I see. No problem.
The code was used in the BR Code Stuffer
http://www.rogersaccesslibrary.com/Otherdownload.asp?
SampleName='BR%20Code%20Stuffer%20Add-In/Builder%20for%
20Access%2097'.

Of course I have this already. I'm pretty sure I have ALL
your samples! :)
I distributed the Code Stuffer as an MDE. There is a
utility in the Code Stuffer that allows the user to
easily create a MsgBox that is actually a
MenuBox with user provided options and captions. If the
Code Stuffer wasn't an MDE I think I could have copied a
form from the Code Stuffer into the developer's MDB.
Because of the MDE, I had to use code to create the form
and add controls. There is a table in the wizard that
contains the properties required to build the form on the
fly. This table was created by using the documenter. You
won't see the code to do this in the Code Stuffer
wizard because it is an MDE file.

Well this is quite interesting. I have played with the
Code Stuffer before, but I must have overlooked that
aspect. I understand about it being an MDE so no code is
available. I never realized you could spontaneously create
forms/controls using information stored in a table. So you
used the Documentor information as a base for the form
information? As Spock would say, "Fascinating."

Do this cause database bloat by constantly creating new
forms/controls?
There are several wizards in Access that create forms and
reports.

Yep, but too bad you can't study the code at how to create
the forms/controls since they are MDE wizards. I vaguely
recall that Microsoft had some wizard code available at
some point in time that could be downloaded. Maybe I'm
mistaken. I'll have to dig around my archives and look
around.
If you use Access 97 and write code but don't use the
Code Stuffer, you should.

Yes, Master. Apologies for my disobedience.
;-)

Thanks again for the information, it has been very
interesting.
 
J

Jeff Conrad

Hi Duane,

Just as a follow-up, I found these Viewable Access 97
Wizard code download files on Microsoft's site:

ACC97: Viewable Wzlib80.mde Code Available in Download
Center:

http://support.microsoft.com/?id=151194

ACC97: Viewable Wzmain80.mde Code Available in Download
Center:

http://support.microsoft.com/?id=151196

ACC97: Viewable Wztool80.mde Code Available in Download
Center:

http://support.microsoft.com/?id=151218

ACC97: Viewable Utility.mda Code Available in Download
Center:

http://support.microsoft.com/?id=151219

Excellent!
I know what I'll be looking at for a while!
 
D

Duane Hookom

Having the viewable wizards doesn't mean all code in the wizards is visible.
There are still snippets that are not available for viewing.

In the BR Code Stuffer wizard, the tables with information to build the form
are in brObjDef and brtblObjProperties. You might want to see how these are
used in the queries in Code Stuffer.
 
J

Jeff Conrad

Hi Duane,

Oh don't worry, I'll be looking through the Code Stuffer
pretty thoroughly!! Thanks for pointing out the specific
tables to look for.

Right now I'm just having fun going through the wizard
code and playing with things. I feel like a kid looking at
the teacher's answer sheet before a big quiz!
<g>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top