Results 1 to 6 of 6

Thread: Importing data into an access mdb via VB

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    In front of Computer
    Posts
    37

    Lightbulb

    I made it possible to import a file into a table with an access macro. I then converted it to VB, and made a program around it, and now i get this error.

    http://home.neo.rr.com/aq2/error.jpg

    all the stuff it needs for the import is there. i have no idea why this is happening, and the strange part, it that it doesnt happen everytime.

    this sux, pleeze help
    ------------------
    "Mess with the best Die like the rest" -Dade "Hackers"

  2. #2

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    In front of Computer
    Posts
    37
    i can post code if that will help

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    In front of Computer
    Posts
    37
    well here is the code

    From Code
    Option Explicit
    'Assumptions
    '-----------
    '1. Database / Textfile / Program are in the same directory
    '2. Textfile name always = mmarptcsv.txt
    '3. Salesman Number = numeric value
    '4. Access is installed on the computer holding the database
    '5. Database is always named salesman.mdb

    Private Sub Command1_Click()
    Dim dbSalesman As Database
    Dim dbLocation As String
    Dim X As Integer
    dbLocation = App.Path & "\salesman.mdb"
    Set dbSalesman = OpenDatabase(dbLocation)
    'Update Database
    Module1.Go
    'Close Database
    dbSalesman.Close
    MsgBox "Update Complete", vbInformation
    'Open Database for deletion of table
    Set dbSalesman = OpenDatabase(dbLocation)
    'Delete table "mmarptcsv_ImportErrors, only if it exists
    For X = 0 To dbSalesman.TableDefs.Count - 1
    If dbSalesman.TableDefs(X).Name = "mmarptcsv_ImportErrors" Then Module1.delete_errors
    Next
    'Close database
    dbSalesman.Close
    End Sub

    Private Sub Command2_Click()
    Set Form1 = Nothing
    Unload Me
    End Sub



    Module Code
    Option Explicit
    Function Go()
    On Error GoTo Go_Err

    Dim sFile As String
    sFile = App.Path & "\mmarptcsv.txt"
    DoCmd.SetWarnings False
    DoCmd.TransferText acImportDelim, "Mmarptcsv Import Specification", "Mmarptcsv", sFile, False, ""
    DoCmd.OpenQuery "Delete", acNormal, acEdit
    DoCmd.OpenQuery "append", acNormal, acEdit
    DoCmd.OpenQuery "clear errors", acNormal, acEdit
    DoCmd.OpenQuery "clear temp", acNormal, acEdit
    DoCmd.SetWarnings True


    Go_Exit:
    Exit Function

    Go_Err:
    MsgBox Error$
    Resume Go_Exit

    End Function

    Function delete_errors()
    On Error GoTo delete_errors_Err

    DoCmd.DeleteObject acTable, "mmarptcsv_ImportErrors"


    delete_errors_Exit:
    Exit Function

    delete_errors_Err:
    MsgBox Error$
    Resume delete_errors_Exit

    End Function


  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    In front of Computer
    Posts
    37
    when the database is open in access, and i run this, it works fine, but when the database is closed, it only periodically werks!!!!

    HELP!!!!

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    In front of Computer
    Posts
    37
    how could i invoke the access macro from in VB, w/o converting the macro to a vb macro?

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    In front of Computer
    Posts
    37
    ok you cant invoke it,


    damn i love how ppl reply to the topics on this board, its soooooo helpful!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width