ODBC call failed, error 3146

MsLady

Traumatized by Access
Local time
Today, 07:38
Joined
Jun 14, 2004
Messages
438
Hello friends, sorry to bother you again :o
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 :confused:

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:
Okay now, i have noticed that i am not able to delete data from a joined table (relationship). But i can delete data from the stand-alone (not joined) tables. i.e. I get this ODBC error when i try to delete the data from tables with join-fields. So does anyone have any idea what i can do here. I need to clean this database off its data. Thanks in advance :D
 
SQLstr1 and SQLstr2 are missing their leading quotes. Is that just a typo?
 
Yes it's just a typo while trying to post it on here. I have about 18 of those queries lined up, so i was trying to shorten it to just 4.
 

Users who are viewing this thread

Back
Top Bottom