I
InspAppsNY
I'm trying to look through each firld in a table using the following code:
Sub PopulateForm()
On Error GoTo TableInfoErr
Dim db As Database
Dim tdf As TableDef
Dim fld As Field
Set db = DBEngine(0)(0)
Set tdf = db.TableDefs("Service Address")
MsgBox ("Service Address table has " & tdf.Fields.Count & " fields")
For Each fld In tdf.Fields
MsgBox (fld.Name)
Call PopulateField(fld.Name)
Next
TableInfoExit:
Set db = Nothing
Exit Sub
TableInfoErr:
Select Case Err
Case 3265 ' Supplied table name invalid
MsgBox strTableName & " table doesn't exist"
Case Else
MSGBOX("TableInfo() Error " & Err & ": " & Error)
End Select
Resume TableInfoExit
End Sub
I have the msgbox's in there so I can tell where the problem is, it displays the MsgBox ("Service Address table has " & tdf.Fields.Count & " fields") correctly, buit then doesn't seem to be doing the "For each fld" part (it doesn't even display the msgbox.) Nor does it call the PopulateField sub (which populates a form in word iwht the value from each field.) What am I doing wrong?
Thanks
Sub PopulateForm()
On Error GoTo TableInfoErr
Dim db As Database
Dim tdf As TableDef
Dim fld As Field
Set db = DBEngine(0)(0)
Set tdf = db.TableDefs("Service Address")
MsgBox ("Service Address table has " & tdf.Fields.Count & " fields")
For Each fld In tdf.Fields
MsgBox (fld.Name)
Call PopulateField(fld.Name)
Next
TableInfoExit:
Set db = Nothing
Exit Sub
TableInfoErr:
Select Case Err
Case 3265 ' Supplied table name invalid
MsgBox strTableName & " table doesn't exist"
Case Else
MSGBOX("TableInfo() Error " & Err & ": " & Error)
End Select
Resume TableInfoExit
End Sub
I have the msgbox's in there so I can tell where the problem is, it displays the MsgBox ("Service Address table has " & tdf.Fields.Count & " fields") correctly, buit then doesn't seem to be doing the "For each fld" part (it doesn't even display the msgbox.) Nor does it call the PopulateField sub (which populates a form in word iwht the value from each field.) What am I doing wrong?
Thanks