I just want to comment on your code. Not about HOW to delete records, but about the commands.
You used the single line syntax of the IF() function;nothing wrong with that. But the only time you should use the GOTO command is in error handling code. (IMHO)
So your original code has this snippet of code:
Code:
If rs.EOF = True Then GoTo NoRecords
'rs.Open "DELETE * FROM tblLocation WHERE left([Location Name],4) ='" & TempName & "'", cn, adOpenKeyset, adLockOptimistic
'rs.Delete
NoRecords:
Call closeConnection
End Sub
Here are 3 other ways of writing the same code:
1)
Code:
If rs.EOF = False Then
'rs.Open "DELETE * FROM tblLocation WHERE left([Location Name],4) ='" & TempName & "'", cn, adOpenKeyset, adLockOptimistic
'rs.Delete
End If
Call closeConnection
End Sub
2)
Code:
If Not rs.EOF Then
'rs.Open "DELETE * FROM tblLocation WHERE left([Location Name],4) ='" & TempName & "'", cn, adOpenKeyset, adLockOptimistic
'rs.Delete
End If
Call closeConnection
End Sub
3)
Code:
If rs.EOF Then
'do nothing
Else
'rs.Open "DELETE * FROM tblLocation WHERE left([Location Name],4) ='" & TempName & "'", cn, adOpenKeyset, adLockOptimistic
rs.Delete
End If
Call closeConnection
End Sub
My 2 cents.....