Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2007

Tip: Looking for answers? Try searching our database.

print out Table Description Property (and Field Descriptions)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Loralee - 23 Jan 2007 05:05 GMT
I am trying to create  2 report:  A and B.  

Report(A)  contains the name and description for each of the tables in my
db, and then Report(B) that lists each each field name and description in
each table.

I am using Allison Balter's example in DAO and am getting an error that the
property ormethod is not available.  I believe it is failing at the
description property.  When I type in "tdf.  " Intellisense does not show
description for tdf or any other variations I've tried.  I don't want all the
properties the Documenter gives me, just a simple list so I can document and
share the definitions of the tables and fields.  (Is the description property
hidden somewhere else?)

Thanks-
Loralee

******************
My code is:

   Dim db As DAO.Database
   Dim tdf As TableDef
   Dim fld As Field
   
   Set db = CurrentDb
   DoCmd.SetWarnings False
   For Each tdf In db.TableDefs
       DoCmd.RunSQL "INSERT INTO tblTableDefs" _
           & "(tableName, TableDesc) " _
           & "VALUES (" & tdf.Name & ", " & tdf.Description & ")"
       Next tdf
   
       DoCmd.SetWarnings True
 
Signature

Loralee

Douglas J. Steele - 23 Jan 2007 12:10 GMT
The Description property doesn't exist unless you've assigned a description
to the table or field.

That means that your code has to handle the error that will occur when you
refer to a non-existant description.

Your Error Handler should be something like:

EH:
 Select Err.Number
   Case 3270
     Resume Next
   Case Else
     MsgBox Err.Number & ": " & Err.Description
     Resume End_Routine
 End Select

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I am trying to create  2 report:  A and B.
>
[quoted text clipped - 33 lines]
>
>        DoCmd.SetWarnings True
Loralee - 28 Jan 2007 17:34 GMT
Thanks- I just got back to working on this, and I added the recommended
errorhandling.  When I run from the immediate window I am still getting a
compile error "method or datamember not found" and when I step through it is
the Description property   (in line:  & "VALUES (" & tdf.Name & ", " &
tdf.Description & ")"    )  that is erroring/light up.

Do the description properties of tables and fields "live" elsewhere?  Did I
write something else wrong?  
Thanks,

Loralee

Signature

Loralee

> The Description property doesn't exist unless you've assigned a description
> to the table or field.
[quoted text clipped - 50 lines]
> >
> >        DoCmd.SetWarnings True
Douglas J. Steele - 28 Jan 2007 18:03 GMT
Try

tdf.Properties("Description")

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Thanks- I just got back to working on this, and I added the recommended
> errorhandling.  When I run from the immediate window I am still getting a
[quoted text clipped - 71 lines]
>> >
>> >        DoCmd.SetWarnings True
Loralee - 29 Jan 2007 02:48 GMT
Perhaps I have the syntax wrong, but I'm getting a Property doesn't exist
error and NOTHING in my table.  "Description" is what is highlighted when it
errs.

I incorporated your suggestion and now have:
**********************
Public Sub EnumerateTables() ' 1-22-07 doesn't work LPO

  Dim db As DAO.Database
  Dim tdf As TableDef
  Dim fld As Field
   
   Set db = CurrentDb
   DoCmd.SetWarnings False
   For Each tdf In db.TableDefs
       DoCmd.RunSQL "INSERT INTO tblTableDefs" _
           & "(tableName, TableDesc) " _
           & "VALUES (" & tdf.Name & ", " & tdf.Properties("Description") &
")"
       Next tdf
   
       DoCmd.SetWarnings True
       
Exit Sub
ErrorHandler:
   Select Case Err.Number
       Case 3270
           Resume Next
       Case Else
           MsgBox Err.Number & ": " & Err.Description
           Resume
   End Select
   
End Sub
Signature

Loralee

> Try
>
[quoted text clipped - 75 lines]
> >> >
> >> >        DoCmd.SetWarnings True
John Spencer - 29 Jan 2007 13:02 GMT
You need to add another line to your code.
  On Error GoTo ErrorHandler

I would also add another variable to your routine
  Dim StrDescription as String
and try to assign the Description property to that variable for use in you
append query.

Also, I would add a test to eliminate system tables (they start with
"MSys"), but you may want them listed.  Obviously, this is your choice.

If Instr(1,Tdf.Name,"MSYS") <> 1 then
  ' Do the work
End If

Public Sub EnumerateTables()
  Dim db As DAO.Database
  Dim tdf As TableDef
  Dim fld As Field

  On Error GoTo ErrorHandler

   Set db = CurrentDb
   DoCmd.SetWarnings False
   For Each tdf In db.TableDefs
       'Get the description and add quote marks around it
       'and handle any description that has a quote mark in it
       'by doubling the internal quotes.
       strDescription = Chr(34) & _
              Replace(tdf.Properties, Chr(34), Chr(34) & Chr(34)) & _
              Chr(34)
       'if that errors then the errhandler kicks in and assigns the string
"NULL"

       DoCmd.RunSQL "INSERT INTO tblTableDefs" _
           & "(tableName, TableDesc) " _
           & "VALUES (" & tdf.Name & ", " & strDescription &  ")"
       Next tdf

       DoCmd.SetWarnings True

Exit Sub
ErrorHandler:
   Select Case Err.Number
       Case 3270
           strDescription = "Null"
           Resume Next
       Case Else
           MsgBox Err.Number & ": " & Err.Description
           Resume
   End Select

End Sub

Signature

John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> Perhaps I have the syntax wrong, but I'm getting a Property doesn't exist
> error and NOTHING in my table.  "Description" is what is highlighted when
[quoted text clipped - 119 lines]
>> >> >
>> >> >        DoCmd.SetWarnings True
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.