Hi
Anyone know where I'm going wrong here? Trying to
1. Add a record to an ADODB recordset
2. Call update to ensure a new record is created and a value given to my autonumber field (TBL1.Unique_No)
3. Scroll back to the new record again
4. Edit a field in that new record based on the newly created autonumber.
I get an error
Here's my code:-
It fails at the second update? I know with DAO you had to do an Rs.Edit but how do you do it in ADO please?
I tried a requery after the update but that crashes it too.
Thnx
Anyone know where I'm going wrong here? Trying to
1. Add a record to an ADODB recordset
2. Call update to ensure a new record is created and a value given to my autonumber field (TBL1.Unique_No)
3. Scroll back to the new record again
4. Edit a field in that new record based on the newly created autonumber.
I get an error
-2147217864 Row cannot be located for updating. Some values may have been changed since it was last read.
Here's my code:-
Code:
Public frm_rstADO As New ADODB.Recordset
Public frm_Cnn As ADODB.Connection
Set frm_Cnn = CurrentProject.Connection
With frm_rstADO
Set .ActiveConnection = frm_Cnn
.Source = SQLLine
.LockType = adLockOptimistic
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open
End With
frm_rstADO.AddNew
frm_rstADO![TBL1.Date_Record_Added] = Now()
frm_rstADO![TBL1.Record_Status] = "(+)"
frm_rstADO.Update
Main_Rec_Unique_No = frm_rstADO![TBL1.Unique_No]
frm_rstADO.MoveFirst
frm_rstADO.Find "[TBL1.Unique_No]=" &
Main_Rec_Unique_No, 0, adSearchForward, 1
If frm_rstADO.BOF Or frm_rstADO.EOF Then
MsgBox "Can't Find New Record!!"
End If
frm_rstADO![TBL1.ID] = Main_Rec_Unique_No
frm_rstADO.Update <------ fails
I tried a requery after the update but that crashes it too.
Thnx