Include TransferText within Transaction?

EPD Hater

Registered User.
Local time
Today, 03:36
Joined
Mar 30, 2003
Messages
50
For the obvious reasons, I'd like to perform inserts within a transaction so that referential integrity is maintained. However, I am still getting Key Violation errors when doing TransferText methods within a transaction. My relationships are setup between the related tables ELMDTL and ELMRSP with Referential Integrity on. Some of the queries run create the underlying detail that is joined to the ELMDTL and ELMRSP tables on a common value.

Are transactions only for SQL updates/inserts/deletes?

Here is my code:

Code:
Private Sub Option1_Click()

    Dim DB As DAO.Database
    Dim WK As DAO.Workspace
    Dim Response As Integer
    Dim FTP As Object
    Dim ErrorString As String
    Dim Dataset As String
    Dim BankCount As Integer

'    On Error GoTo Handler

    Set WK = DBEngine.Workspaces(0)
    Set DB = CurrentDb

        DoCmd.SetWarnings False
    WK.BeginTrans
        DoCmd.TransferText acImportFixed, "ELMDTL Import Specification", "ELMDTL", "J:\acctng\COMMON\Data Support\Elmrec\ELMDTL.TXT"
        DoCmd.TransferText acImportFixed, "ELMRSP Import Specification", "ELMRSP", "J:\acctng\COMMON\Data Support\Elmrec\ELMRSP.TXT"
        DoCmd.TransferText acImportDelim, "M&T Detail - 16", "ELMBANK", "J:\acctng\COMMON\Data Support\Elmrec\ELMBANK.TXT"
        DoCmd.OpenQuery "Qry_Crop"
        DoCmd.OpenQuery "Qry_NegateDebits"
        DoCmd.OpenQuery "Qry_BankExt"
        DoCmd.OpenQuery "Qry_RostrSum"
        DoCmd.OpenQuery "Qry_RespSum"
        DoCmd.OpenQuery "Qry_UpdateDailyBalance"
        DoCmd.RunSQL "UPDATE [Tbl_DailyBalance] SET [Import] = -1, [GDG] = " & Dataset & " WHERE Format$([ProcessDate],'mm/dd/yyyy') = Format$(Now(),'mm/dd/yyyy') WITH OWNERACCESS OPTION"
    WK.CommitTrans
        BankCount = DCount("[Amount]", "[tbl_BankExt]", "[BankClearInd] = 0 AND [Date] = DMax('[Date]', '[Tbl_BankExt]')")
        If BankCount = 0 Then MsgBox "There is no bank activity for the current day.", vbInformation, "Bank Items"
        MsgBox "Records have been imported into the database.", vbInformation, "Import Completed"
        DoCmd.SetWarnings True

    End If
    Exit Sub

Handler:
    MsgBox Err.Number & ": " & Err.Description, vbCritical, "Error"
    Exit Sub

End Sub
 

Users who are viewing this thread

Back
Top Bottom