Cobra17
Mechanical
- Jun 18, 2020
- 163
I'm trying to loop through a table records and fields. The field loops work fine, but I can't get it to move down to the next "tbl" record..
i'm using 3 record sets all based on the same table
tbl = the set I want to loop through
rst1 = loops through table field names and compares against rst2
rst2 = loops through table field names
I was thinking that maybe an SQL statement would work with to copy and paste if ID_Vessel = OldVesID AND Est_ID - OldEst... but i'm not sure how i could replace only the copied ID_Vessel & Est_ID with NewVesID & NewEst. or maybe some other nice and easy way.
i'm using 3 record sets all based on the same table
tbl = the set I want to loop through
rst1 = loops through table field names and compares against rst2
rst2 = loops through table field names
Code:
tbl.MoveFirst
Do While Not tbl.EOF
If tbl!ID_Vessel = OldVesID And tbl!Est_ID = OldEst Then
With rst1
.AddNew
!ID_Vessel = NewVesID
!Est_ID = NewEst
For Each fld1 In rst1.Fields
If fld1.Name <> "ID" And fld1.Name <> "ID_Vessel" And fld1.Name <> "Est_ID" Then
For Each fld2 In rst2.Fields
If fld1.Name = fld2.Name Then
If IsFieldCalculated(tblName, fld2.Name) <> True Then
fld1 = fld2
End If
End If
Next fld2
End If
Next fld1
.Update
.Close
End With
End If
tbl.MoveNext
Loop
I was thinking that maybe an SQL statement would work with to copy and paste if ID_Vessel = OldVesID AND Est_ID - OldEst... but i'm not sure how i could replace only the copied ID_Vessel & Est_ID with NewVesID & NewEst. or maybe some other nice and easy way.