General information
Category:
Database DAO/RDO/ODBC/ADO
Yes, There is no Edit method for ADO, but you can use Select statement and then trap the error code, the codes should be as follow:
On Error goto ErrorHandler
Dim mSQL as String
Dim rsMyRecord as ADODB.Recordset
mSQL = "Select * from MyTable Where MyCode = 'myCriteria' Order by MyCode"
rsMyRecord.Open mSQL,YourConnectionString ..., adOpenKeyset, adLockOptimistic
rsMyRecord.MoveLast
rsMyRecord!MyField1 = ...
rsMyRecord!MyField2 = ...
rsMyRecord.Update
rsMyRecord.Close
ErrorHandler:
Select Case Err.Number
case 0
Case 3021 ' Specified Record not found
' You May Add New Record Here
Resume next
Case else ' Trap another errors
...
...
End select
Best Regards
Winan
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only