tbldefs to obtain field descriptions

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

When using tbldefs to look at the fields
collection with DAO, I don't seem to find
a specific mention or method wherein one
can obtain the field's "description" string.
Is there such a method?

I have a nasty data migration task that
would be made easier and more reliable
if I could parse what is already an established
fixed syntax of the field description strings.

Thanks,
Bill
 
You can use something like:

On Error Resume Next

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim fldCurr As DAO.Field
Dim strToPrint As String

Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
strToPrint = tdfCurr.Name
strToPrint = strToPrint & ": " & tdfCurr.Properties("Description")
If Err.Number = 3270 Then
strToPrint = strToPrint & ": No Description"
Err.Clear
Else
MsgBox Err.Number & ": " & Err.Description
Exit Sub
End If
Debug.Print strToPrint
For Each fldCurr In tdfCurr.Fields
strToPrint = fldCurr.Name
strToPrint = strToPrint & ": " & fldCurr.Properties("Description")
If Err.Number = 3270 Then
strToPrint = strToPrint & ": No Description"
Err.Clear
Else
MsgBox Err.Number & ": " & Err.Description
Exit Sub
End If
Next fldCurr
Next tdfCurr
 
Doug,

With the initial running of your code, the tables
themselves in the DB didn't have descriptions.
I got the "0:" MsgBox and one line in the immediate
window, "Assets: no description". As soon as I added
descriptions to the 7 tables in the DB, all that I got was
the MsgBox "0:".

All of the fields in the Assets table have descriptions.

I don't see the problem.

Bill
 
Hi Bill (and Doug)

In my browsing, this thread seemed interesting, so I tried Doug's routine.
I also added check for error 0, and debug.print for field names.

The only thing I'd add is that the immediate window may overflow for large
numbers of tables/fields - it does in my test database, which is full of all
sorts of stuff ;-) If that's the case, you could write strPrint to a text
file, rather than to the immediate window.

HTH,

Rob
 
That's because I wasn't paying attention to what I wrote!


On Error Resume Next

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim fldCurr As DAO.Field
Dim strToPrint As String

Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
strToPrint = tdfCurr.Name
strToPrint = strToPrint & ": " & tdfCurr.Properties("Description")
If Err.Number <> 0 Then
If Err.Number = 3270 Then
strToPrint = strToPrint & ": No Description"
Err.Clear
Else
MsgBox Err.Number & ": " & Err.Description
Exit Sub
End If
End If
Debug.Print strToPrint
For Each fldCurr In tdfCurr.Fields
strToPrint = fldCurr.Name
strToPrint = strToPrint & ": " & fldCurr.Properties("Description")
If Err.Number <> 0 Then
If Err.Number = 3270 Then
strToPrint = strToPrint & ": No Description"
Err.Clear
Else
MsgBox Err.Number & ": " & Err.Description
Exit Sub
End If
End If
Next fldCurr
Next tdfCurr


Error 0 means there is no error!

Sorry about that.
 
Back
Top