Programming Documentation Options

G

Guest

I want to do up some documentation for the fields in a table. I was going
to use this example as a guide. I want two of my fields in my documentation
table )if it is a combo box) to be the value list and whether the field is
limited to list.

How do I do this?

http://www.tek-tips.com/viewthread.cfm?qid=1244914&page=8

Sample of code:
For Each tdf In db.TableDefs
If (tdf.Attributes And dbSystemObject) = 0 Then
strName = tdf.Name
If strName <> "AA_Tables" Then
For Each fld In tdf.Fields
With rs
.AddNew
!tablename = strName
!FieldName = fld.Name
!fieldType = FieldTypeName(fld)
!FieldSize = fld.Size
!fieldDescription = GetDescrip(fld)
.Update
End With
Next
End If
End If
Next
 
G

Guest

When you say "if it is a combo box", are you saying that you've defined some
fields as Lookup fields? You may be interested in seeing why many of us think
that's a bad idea: http://www.mvps.org/access/lookupfields.htm

In any case, if a field has been set up to use a combo box, it will have a
property named DisplayControl, with a value of 111 (I'll leave it to you to
discover what other values DisplayControl can have! <g>) The problem is, the
DisplayControl property doesn't exist unless you've set it. That means if you
try referring to it, and it wasn't set, you're going to get an Error 3270
("Property Not Found")

You'll need to add error checking to your routine, and simply continue when
you encounter an Error 3270:

On Error GoTo ErrHandler

For Each tdf In db.TableDefs
If (tdf.Attributes And dbSystemObject) = 0 Then
strName = tdf.Name
If strName <> "AA_Tables" Then
For Each fld In tdf.Fields
With rs
.AddNew
!tablename = strName
!FieldName = fld.Name
!fieldType = FieldTypeName(fld)
!FieldSize = fld.Size
!fieldDescription = GetDescrip(fld)
If (fld.Properties("DisplayControl") = 111) Then
!fieldValueList = fld.Properties("RowSource")
!fieldLimitToList = fld.Properties("LimitToList")
End If
.Update
End With
Next
End If
End If
Next

EndSub:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 3270
Resume Next
Case Else
MsgBox Err.Number & ": " & _
Err.Description
Resume EndSub
End Select
 
G

Guest

Thanks

Doug Steele said:
When you say "if it is a combo box", are you saying that you've defined some
fields as Lookup fields? You may be interested in seeing why many of us think
that's a bad idea: http://www.mvps.org/access/lookupfields.htm

In any case, if a field has been set up to use a combo box, it will have a
property named DisplayControl, with a value of 111 (I'll leave it to you to
discover what other values DisplayControl can have! <g>) The problem is, the
DisplayControl property doesn't exist unless you've set it. That means if you
try referring to it, and it wasn't set, you're going to get an Error 3270
("Property Not Found")

You'll need to add error checking to your routine, and simply continue when
you encounter an Error 3270:

On Error GoTo ErrHandler

For Each tdf In db.TableDefs
If (tdf.Attributes And dbSystemObject) = 0 Then
strName = tdf.Name
If strName <> "AA_Tables" Then
For Each fld In tdf.Fields
With rs
.AddNew
!tablename = strName
!FieldName = fld.Name
!fieldType = FieldTypeName(fld)
!FieldSize = fld.Size
!fieldDescription = GetDescrip(fld)
If (fld.Properties("DisplayControl") = 111) Then
!fieldValueList = fld.Properties("RowSource")
!fieldLimitToList = fld.Properties("LimitToList")
End If
.Update
End With
Next
End If
End If
Next

EndSub:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 3270
Resume Next
Case Else
MsgBox Err.Number & ": " & _
Err.Description
Resume EndSub
End Select
 

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