This is the vba code
Set db = CurrentDb
On error goto fErr
…. loop
strSql = "UPDATE tblInvAnalysisWhse" & _
" SET ltDeviation = " & Sqr(dblError /
intPeriods) & _
" WHERE item = '" & Trim(strItem) & "'" & _
" AND location = " & intLocation
dblCount = dblCount + 1
db.Execute strSql, dbFailOnError
fErr:
stop
resume next
db.execute always fails after 1246 iterations, with
- [Microsoft][ODBC SQL Server Driver]Timeout
expired ,ODBC.Database ,0
- ODBC--update on a linked table 'tblInvAnalysisWhse'
failed. ,DAO.Database ,3157
'tblInvAnalysisWhse’ has 107,000+ records, and is a linked sql server
table
Columns item & location are indexed
Strsql on failure is
UPDATE tblInvAnalysisWhse
SET ltDeviation = 9
WHERE item = 'P103 L25348' AND location = 21
If I try to execute the UPDATE statement in sql server, it never
completes (8 mins and running)
There’s nothing in the sql server logs
And my process only has 20 object locks
Until I 'stop' running the ms-access function, and then the sql server
statement completes immediately
Of course, all the locks are gone
so the problem has to do with locks
So what do I need to do, in a vba loop, to free up my sql server locks
after each update statement ?
create a transaction ?
create a passthrough query to do the update ?