Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft Access > Re: Creating a ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 8 Topic 30184 of 31596
Post > Topic >>

Re: Creating a code book from Access 2003

by timmg <tmillsgroninger@[EMAIL PROTECTED] > May 8, 2008 at 06:32 AM

On May 6, 11:13=A0am, "mlthomas007" <u43434@[EMAIL PROTECTED]
> wrote:
> Hi,
>
> A client asked for a code book (all fields, descriptions, tables, etc.)
fr=
om
> our Access database. =A0Has anyone had to do this? =A0It seems to me
there=
 must
> be a way to extract all this information from Access.

I use a re****t called tblFields with the following code.  The re****t
groups on table names and shows the field descriptions.  Sometimes
this is eough for the client, sometimes I send it into Word and
explain a little more what's going on.  I can copy the re****t to any
application for a quick look of what's what.

Private Sub Re****t_Open(Cancel As Integer)
' Arvin Meyer 12/7/1995
' Modified 3/17/2000 Tim Mills-Groninger
' Finds and lists all fields in all tables

On Error Resume Next
Me.CreateNewTableWithChecking =3D Null 'check for tblFields, make if not
present

Dim db As Database
Dim rst As Recordset
Dim tdf As TableDef
Dim fld As Field
Dim intI As Integer
Dim intJ As Integer
Dim strDesc As String

Set db =3D CurrentDb()
' Clean out the "working" table tblFields
db.Execute "Delete * From tblFields"
  ' Open the table for data entry
  Set rst =3D db.OpenRecordset("tblFields", DB_OPEN_TABLE,
DB_APPENDONLY)
  ' Outer loop for tables
  For intI =3D 0 To db.TableDefs.Count - 1
    Set tdf =3D db.TableDefs(intI)
    ' Skip system tables
    If Left(tdf.Name, 4) <> "MSys" Then
      ' Now loop through fields
      For intJ =3D 0 To tdf.Fields.Count - 1
        Set fld =3D tdf.Fields(intJ)
        rst.AddNew
        rst!TableName =3D tdf.Name
        rst!FieldName =3D fld.Name
        rst!FieldNumber =3D fld.OrdinalPosition
        Select Case fld.Type
          Case dbDate
            rst!DataType =3D "Date/Time"
          Case dbText
            rst!DataType =3D "Text"
          Case dbMemo
            rst!DataType =3D "Memo"
          'Case dbHyperlinkField
          '  rst!DataType =3D "Hyperlink"
          Case dbBoolean
            rst!DataType =3D "Yes/No"
          Case dbInteger
            rst!DataType =3D "Integer"
          Case dbLong
            rst!DataType =3D "Long Integer"
          Case dbCurrency
            rst!DataType =3D "Currency"
          Case dbSingle
            rst!DataType =3D "Single"
          Case dbDouble
            rst!DataType =3D "Double"
          Case dbByte
            rst!DataType =3D "Byte"
          Case dbLongBinary
            rst!DataType =3D "OLE Field"
          Case Else
            rst!DataType =3D "Unknown"
          End Select
        strDesc =3D ""
        ' The Resume Next will avoid an error if there is no
Description
        strDesc =3D fld.Properties("Description")
        rst!Description =3D IIf(IsNull(fld.Properties("Description")),
"", strDesc)
        rst.Update
      Next intJ
    End If
  Next intI
  rst.Close
End Sub

Function CreateNewTableWithChecking()
' check for table fields, and if not present, make one
' Helen Feddema - the Access Archon, modified from her column
' in Woody's Access Watch Vol2 No11

On Error GoTo ErrorHandler

   Dim dbs As DAO.Database
   Dim strTable As String
   Dim strSQL As String
   Dim tdf As TableDef
   Dim lngResult As Long

   Set dbs =3D CurrentDb
   strTable =3D "tblFields"
   Set tdf =3D dbs.TableDefs(strTable)
   'dbs.TableDefs.Delete strTable

CreateNewTable: 'Runs only if "tblFields" does not exist

    strSQL =3D "CREATE TABLE  " & strTable & "(TableName TEXT (50),
FieldName TEXT (50), "
    strSQL =3D strSQL + " FieldNumber INTEGER, DataType TEXT (50),
DefaultValue TEXT (50)"
    strSQL =3D strSQL + " , Description TEXT (150), Constraint myCon
Primary Key (TableName, FieldName));"

    dbs.Execute strSQL

ErrorHandlerExit:

   Exit Function

ErrorHandler:

   Select Case Err.Number
      Case 3265
        GoTo CreateNewTable
      Case Else
         'MsgBox "Error No: " & Err.Number & "; Description: " &
Err.Description
         Resume ErrorHandlerExit
   End Select

End Function
 




 8 Posts in Topic:
Creating a code book from Access 2003
"mlthomas007" &  2008-05-06 16:13:04 
Re: Creating a code book from Access 2003
fredg <fgutkind@[EMAIL  2008-05-06 09:58:34 
Re: Creating a code book from Access 2003
"mlthomas007 via Acc  2008-05-07 19:54:57 
Re: Creating a code book from Access 2003
"Larry Linson"   2008-05-07 17:26:43 
Re: Creating a code book from Access 2003
"mlthomas007 via Acc  2008-05-07 19:49:57 
Re: Creating a code book from Access 2003
"mlthomas007 via Acc  2008-05-08 15:12:13 
Re: Creating a code book from Access 2003
"Larry Linson"   2008-05-08 18:34:46 
Re: Creating a code book from Access 2003
timmg <tmillsgroninger  2008-05-08 06:32:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 11:51:52 CST 2008.