Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column?

Tags:

sql-server

vba

Private Sub update ()    
   Dim db As Database
   Set db = CurrentDb
   Dim rs As Recordset

   Set rs = db.OpenRecordset("SELECT * From Table", dbOpenDynaset, dbSeeChanges)
   db.Execute ("UPDATE Table SET Path = '" & A.Value & "' WHERE B = '" & B.Value & "'")

   db.Close
End Sub

When I got vba access Error 3622 (i.e use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column) a proposed solution was to add the first line (Set rs=... see above in the coding) which I did but it did not resolve the problem. Is there another way to avoid this error ?

I am new in coding and would appreciate any help on this. Thank you.

like image 407
user3405572 Avatar asked Mar 18 '14 17:03

user3405572


1 Answers

Since OP has disappeared - add dbSeeChanges to the end of the command (VBA):

DBEngine(0)(0).Execute "UPDATE Table SET Path = '" & A.Value & "' WHERE B = '" & B.Value & "'", dbSeeChanges
like image 101
rrrhys Avatar answered Nov 11 '22 12:11

rrrhys