M
Maury Markowitz
We have a bunch of very similar tables that we periodically clean out. I
wanted to place all the clearing out code in one place, erroring over the
ones that don't work (see below).
However this only works for the first attempt, on the second one it still
returns the error. Why? I've tried lots of things like ERR.CLEAR, ON ERROR 0,
ON ERROR RESUME NEXT, etc., but nothing helps.
Why will this only trap once?
On Error GoTo tryAgain1
Set rsttemp = New ADODB.Recordset
rsttemp.Open "DELETE FROM " & tempname & " WHERE lastModifiedBy = '" &
loggedInUserId & "'", cnn, adOpenForwardOnly, adLockOptimistic
GoTo exitOut
tryAgain1:
On Error GoTo tryAgain2
Set rsttemp = New ADODB.Recordset
rsttemp.Open "DELETE FROM " & tempname & " WHERE lastModifiedById = '" &
loggedInUserId & "'", cnn, adOpenForwardOnly, adLockOptimistic
GoTo exitOut
tryAgain2:
On Error GoTo tryAgain3
Set rsttemp = New ADODB.Recordset
rsttemp.Open "DELETE FROM " & tempname & " WHERE modifiedBy = '" &
loggedInUserId & "'", cnn, adOpenForwardOnly, adLockOptimistic
GoTo exitOut
tryAgain3:
exitOut:
Err.Clear
On Error GoTo 0
wanted to place all the clearing out code in one place, erroring over the
ones that don't work (see below).
However this only works for the first attempt, on the second one it still
returns the error. Why? I've tried lots of things like ERR.CLEAR, ON ERROR 0,
ON ERROR RESUME NEXT, etc., but nothing helps.
Why will this only trap once?
On Error GoTo tryAgain1
Set rsttemp = New ADODB.Recordset
rsttemp.Open "DELETE FROM " & tempname & " WHERE lastModifiedBy = '" &
loggedInUserId & "'", cnn, adOpenForwardOnly, adLockOptimistic
GoTo exitOut
tryAgain1:
On Error GoTo tryAgain2
Set rsttemp = New ADODB.Recordset
rsttemp.Open "DELETE FROM " & tempname & " WHERE lastModifiedById = '" &
loggedInUserId & "'", cnn, adOpenForwardOnly, adLockOptimistic
GoTo exitOut
tryAgain2:
On Error GoTo tryAgain3
Set rsttemp = New ADODB.Recordset
rsttemp.Open "DELETE FROM " & tempname & " WHERE modifiedBy = '" &
loggedInUserId & "'", cnn, adOpenForwardOnly, adLockOptimistic
GoTo exitOut
tryAgain3:
exitOut:
Err.Clear
On Error GoTo 0