Z
Zikar
Hi all Group members,
I am in the process of building a code to update a table field I call
[Transitional_Temp_ITP_ID] and is a Long Integer. The value of this filed has
to be updated to become equal to the Primary Key field which is an autonumber
and I call it [ITP_Master_ID]. I have set a criterion where the only records
in which a third field within the same table I called [ProjectID], which is a
Long Integer, is equal to zero. The code I wrote is as follows:
Dim rst As Recordset
Dim db As Database
Set db = CurrentDb()
Set rst = CurrentDb.OpenRecordset("SELECT * FROM
Tbl_QA_ITP_ProjectList_Parent WHERE ProjectID = " & 0)
rst.MoveFirst
If Not rst.NoMatch Then
rst.Edit
rst![Transitional_Temp_ITP_ID] = rst![ITP_Master_ID]
rst.Update
End If
Now, this code works but it only updates the first record while I want it to
update all the records that meet my set criterion; that is where the third
field called ProjectID = 0. I know that this could be because I did not set
the " For each" and "Next" iteration code within this event and that could be
the reason it is not doing the update for the rest of the records. Can
someone help me with this desperate situation? Great thanks in advance to all
of you who make this workgroup site a great place to share information and
make others achieve many wonderful things and great work with Microsoft
Access!
I am in the process of building a code to update a table field I call
[Transitional_Temp_ITP_ID] and is a Long Integer. The value of this filed has
to be updated to become equal to the Primary Key field which is an autonumber
and I call it [ITP_Master_ID]. I have set a criterion where the only records
in which a third field within the same table I called [ProjectID], which is a
Long Integer, is equal to zero. The code I wrote is as follows:
Dim rst As Recordset
Dim db As Database
Set db = CurrentDb()
Set rst = CurrentDb.OpenRecordset("SELECT * FROM
Tbl_QA_ITP_ProjectList_Parent WHERE ProjectID = " & 0)
rst.MoveFirst
If Not rst.NoMatch Then
rst.Edit
rst![Transitional_Temp_ITP_ID] = rst![ITP_Master_ID]
rst.Update
End If
Now, this code works but it only updates the first record while I want it to
update all the records that meet my set criterion; that is where the third
field called ProjectID = 0. I know that this could be because I did not set
the " For each" and "Next" iteration code within this event and that could be
the reason it is not doing the update for the rest of the records. Can
someone help me with this desperate situation? Great thanks in advance to all
of you who make this workgroup site a great place to share information and
make others achieve many wonderful things and great work with Microsoft
Access!