gdev
Technical User
- Mar 12, 2001
- 38
Hi,
I have 3 fields in a table; when the item gets to the second field,
I get this error message: item not found in this collection.
Here's the code I am using:
Dim x As Integer
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim strField As String
Set db = CurrentDb
Set tdf = db.TableDefs("tTest")
For x = 0 To tdf.Fields.Count - 1
Set fld = tdf.Fields(x)
strField = fld.Name
Debug.Print strField
Debug.Print x
If strField <> "1stField" Then
tdf.Fields.Delete (strField)
Debug.Print strField
End If
Next
Set db = Nothing
Set tdf = Nothing
Please tell me what I'm doing wrong.
Thanks
Gwen
I have 3 fields in a table; when the item gets to the second field,
I get this error message: item not found in this collection.
Here's the code I am using:
Dim x As Integer
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim strField As String
Set db = CurrentDb
Set tdf = db.TableDefs("tTest")
For x = 0 To tdf.Fields.Count - 1
Set fld = tdf.Fields(x)
strField = fld.Name
Debug.Print strField
Debug.Print x
If strField <> "1stField" Then
tdf.Fields.Delete (strField)
Debug.Print strField
End If
Next
Set db = Nothing
Set tdf = Nothing
Please tell me what I'm doing wrong.
Thanks
Gwen