| DatabaseLessons.com |
'Serving the Microsoft® Access |
|
|
Faster DocumentationBoth Access 97 and Access 2000 have a documentation generator under the menu Tools, Analyze. I use it mainly to print out a list of the fields in a table. I use these lists for a variety of things. (article continues after sponsor spot) Well, when I first used Access 2000 I found it hard to believe that this documentation feature had become so slow. A posting on a newsgroup got the, "That's the way it is." answer. So, I created my own. Much faster than the one in Access. Here is how I did it. NOTE: All the VBA code segments on the Database Lessons site assume that you have DAO references active. If you are not sure what this means, and you are using Microsoft Access 2000 or higher, click here. Created a table (tblFields) to hold the field names and their types and sizes (ID as autonumber (primary key), TableName as text*50, FieldName as text*50, FieldType as text*20, FieldSize as integer) Created a form (frmDoc) and put 3 objects on it. (a) text box (strDBName) to type in the name of the database to document, (b) button (cmdDoc) to start the process, and (c) button (cmdExit) to exit. Put the appropriate code behind the 2 buttons. Created a report to print out the list of fields (sort on TableName and ID, group by TableName, new page after each table) Obviously, the key to this faster Access Documentation tool is in the code. Behind cmdExit
Behind cmdDoc
On Error GoTo error_Print
' Create Microsoft Jet Workspace object.
' Open Database object
db2.Execute ("delete * from tblFields")
Set rst = db2.OpenRecordset("select * from tblFields")
For Each tbl In db.TableDefs
DoCmd.OpenReport "rptDoc", acViewPreview
Exit Sub
error_Print:
End Sub
'------------------------------------------------------
Function basFieldType(intType As Integer) As String
Select Case intType
End Function It is left to the reader to expand this to include indexes, and/or convert to ADO. Also, add a common dialogue box feature so you can point and click on the desired database. |
|
|
© 2006, 2007 Richard W. Killey. All Rights Reserved. |