gmaxey
05-20-2013, 10:15 PM
I'm trying to delete a row from a table in a database:
'This works because the table is deleted.
oConn.Execute "DROP TABLE [" & NumberingDlg.lbxSavedSchemes & "]"
'Now I want to delete a row in another table named "tblNumSchemes" in the same database.
On Error Resume Next
oConn.Execute "DROP INDEX [" & NumberingDlg.lbxSavedSchemes & "] ON tblNumSchemes"
If Err.Number <> 0 Then
Debug.Print Err.Number & " " & Err.Description
'Returns -2147217900 The database engine could not lock table 'tblNumSchemes' because it is already in use by another person or process.
End If
On Error GoTo 0
'This line runs without error, but the row is not deleted :-(
oConn.Execute "DELETE FROM tblNumSchemes WHERE fldNumSchemeName='[" & NumberingDlg.lbxSavedSchemes & "]'"
I'm a beginner here taking baby steps and I'm not even sure that I am using the rigth methods. I've looked on line and from what I found, it seems that either method I used should work.
Can anyone explain what I've done wrong and offer a suggestion to correct it. Thanks.
'This works because the table is deleted.
oConn.Execute "DROP TABLE [" & NumberingDlg.lbxSavedSchemes & "]"
'Now I want to delete a row in another table named "tblNumSchemes" in the same database.
On Error Resume Next
oConn.Execute "DROP INDEX [" & NumberingDlg.lbxSavedSchemes & "] ON tblNumSchemes"
If Err.Number <> 0 Then
Debug.Print Err.Number & " " & Err.Description
'Returns -2147217900 The database engine could not lock table 'tblNumSchemes' because it is already in use by another person or process.
End If
On Error GoTo 0
'This line runs without error, but the row is not deleted :-(
oConn.Execute "DELETE FROM tblNumSchemes WHERE fldNumSchemeName='[" & NumberingDlg.lbxSavedSchemes & "]'"
I'm a beginner here taking baby steps and I'm not even sure that I am using the rigth methods. I've looked on line and from what I found, it seems that either method I used should work.
Can anyone explain what I've done wrong and offer a suggestion to correct it. Thanks.