I am trying to get the value of fields in a table which I am iterating through.Here is the code I am using
Sub FieldNameAndValue()
Dim dbs As DATABASE, tdf As TableDef
Dim fld As Field
Dim fldname As String, fldvalue As String
Dim FieldCount As Long
Dim i As Integer
' Return Database variable that points to current database.
Set dbs = CurrentDb
Set tdf = dbs.TableDefs!Cust
FieldCount = tdf.Fields.Count
For Each fld In tdf.Fields
fldname = tdf.Fields(i).Name
fldvalue = tdf!fldname.Value
MsgBox "There are " & Str(FieldCount) & " field(s)" & Chr(13) & "The field position is " & Str(i) & Chr(13) _
& "The field name is " & fldname & Chr(13) & "The field value is " & fieldvalue
i = i + 1
Next fld
End Sub
What syntax should I use?
Thanks,
Dennis
Sub FieldNameAndValue()
Dim dbs As DATABASE, tdf As TableDef
Dim fld As Field
Dim fldname As String, fldvalue As String
Dim FieldCount As Long
Dim i As Integer
' Return Database variable that points to current database.
Set dbs = CurrentDb
Set tdf = dbs.TableDefs!Cust
FieldCount = tdf.Fields.Count
For Each fld In tdf.Fields
fldname = tdf.Fields(i).Name
fldvalue = tdf!fldname.Value
MsgBox "There are " & Str(FieldCount) & " field(s)" & Chr(13) & "The field position is " & Str(i) & Chr(13) _
& "The field name is " & fldname & Chr(13) & "The field value is " & fieldvalue
i = i + 1
Next fld
End Sub
What syntax should I use?
Thanks,
Dennis