Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute SQL causes IDENTITY issue with one statement but not other

Status
Not open for further replies.

03Explorer

Technical User
Sep 13, 2005
304
US
I have code that updates a table with two different but similar fields to be updated. Neither updates deal directly with an IDENTITY column. However ONE of them uses the IDENTITY column in the WHERE statement. The 2nd code works like expected... the first crashes saying "You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column."

Table in question is a linked table (MS SQL table)

Code:
SQL = "UPDATE tblSurveysPreGenerated SET [PreGeneratedStatus] = 3, [GeneratedDate] = #" & Date & "#, [GeneratedTime] = #" & Format(Now(), "hh:nn:ss") & "#, [Processed] = 1 WHERE PreGeneratedAutoID = " & rsPreGenerated!PreGeneratedAutoID & "; "
db.Execute SQL

SQL = "UPDATE tblSurveysPreGenerated SET [PreGeneratedStatus] = 4, [Processed] = 1 WHERE isNull([Processed]) AND isNull([GeneratedDate]) AND isNull([GeneratedTime]); "
db.Execute SQL

Recap: line of code with 3 crashes; the line of code with 4 works

Any rhyme to the reason why 3 code is giving IDENTITY error and not 4?
 
I think this is just a quirk of SQL server updates from Access. You can add the ,dbSeeChanges to the Execute statement.

I typically have a generic pass-through query that I update the SQL property and then Execute.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thanks Duane, I ended up using dbSeeChanges

The problem is not there, but it still leaves me to wonder ;)
 
Combo said:
MS states that "You should also use the dbSeeChanges constant if you open a Recordset in a Microsoft Access database engine-connected ODBC workspace against a Microsoft SQL Server 6.0 (or later) table that has an IDENTITY column, otherwise an error may result."

Thank you, great to know.
=)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top