I have a section of code that appears below. It is intended to update the field "trans" in the table "Stran" with sequential numbers (beginning with '100' in this case). The code works fine when the field is referenced as "myset.Fields(2) = mycounter" but fails with the "Item not found in this collection" error when the actual field name is used in the reference aka either...
myset.Fields![trans] = mycounter
myset.Fields("trans") = mycounter
Does anyone know why this would be?
'CODE
Dim MyDB As DAO.Database
Dim myset As DAO.Recordset
Dim mycounter As Integer
Dim criteria As String
mycounter = 100
criteria = "[Item] >= 0"
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set myset = MyDB.OpenRecordset("Stran", DB_OPEN_DYNASET)
myset.FindFirst criteria
Do Until myset.NoMatch
myset.Edit
myset.Fields(2) = mycounter
mycounter = mycounter + 1
myset.Update
myset.FindNext criteria
Loop
myset.Fields![trans] = mycounter
myset.Fields("trans") = mycounter
Does anyone know why this would be?
'CODE
Dim MyDB As DAO.Database
Dim myset As DAO.Recordset
Dim mycounter As Integer
Dim criteria As String
mycounter = 100
criteria = "[Item] >= 0"
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set myset = MyDB.OpenRecordset("Stran", DB_OPEN_DYNASET)
myset.FindFirst criteria
Do Until myset.NoMatch
myset.Edit
myset.Fields(2) = mycounter
mycounter = mycounter + 1
myset.Update
myset.FindNext criteria
Loop