MsLady
Traumatized by Access
- Local time
- Today, 07:38
- Joined
- Jun 14, 2004
- Messages
- 438
Hello friends, sorry to bother you again
But i am trying to run this event to delete all records from tables and i get ODBC call failed, error 3146. Do anyone have any idea why?
ps: it runs when i comment all the order sql statement except one. meaning, it looks like only one can run at a time
I have searched the forum and google, but can't seem to find anything helpful
But i am trying to run this event to delete all records from tables and i get ODBC call failed, error 3146. Do anyone have any idea why?
ps: it runs when i comment all the order sql statement except one. meaning, it looks like only one can run at a time
Code:
On Error GoTo Err_cmdImportData
Dim ws As DAO.Workspace 'Current workspace (for transaction).
Dim db As DAO.Database 'Inside the transaction.
Dim strOldDBpath As String
Dim SQLstr1 As String, SQLstr2 As String, SQLstr3 As String, SQLstr4 As String
'Initialize database object inside a transaction.
Set ws = DBEngine(0)
ws.BeginTrans
bInTrans = True
Set db = ws(0)
SQLstr1 = "DELETE * FROM Projectstatus;"
db.Execute SQLstr1, dbFailOnError
SQLstr2 = "DELETE * FROM ProjectCategories;"
db.Execute SQLstr2, dbFailOnError
dSQL3 = "DELETE * FROM projectAllocations;"
db.Execute dSQL3, dbFailOnError
dSQL4 = "DELETE * FROM projectStatusCommentary;"
db.Execute dSQL4, dbFailOnError
' Get user confirmation to commit the change.
strMsg = "Proceed to copying data?"
If MsgBox(strMsg, vbOKCancel + vbQuestion, "Confirm") = vbOK Then
ws.CommitTrans
bInTrans = False
Beep
'MsgBox "Archive complete!"
MsgBox "Data Copied!", vbInformation, "Copy Completed"
End If
Exit_cmdImportData:
On Error Resume Next
Set db = Nothing
If bInTrans Then 'Rollback if the transaction is active.
ws.Rollback
End If
Set ws = Nothing
Exit Sub
Err_cmdImportData:
MsgBox Err.Description, vbExclamation, "Data Import Failed: Error " & Err.Number
Resume Exit_cmdImportData
End Sub
I have searched the forum and google, but can't seem to find anything helpful
Last edited: