Results 1 to 9 of 9

Thread: Import CSV

  1. #1
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Angry Unanswered: Import CSV

    I am trying to import a CSV file by code.

    I do this:

    .TransferText acImportDelim, , "DeliveryImport", "M:\Output.csv", False

    It's not working.
    But if I use the wizard there are some errors about conversion of date data. But it's doing the import in a table.

    what's the problem?

    Thank you

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    What is the message error you get?

  3. #3
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    ****

    Microsof Access was unable to append all the data to the table.

    The contents of fields in 0 records were deleted, and 0 records were lost to key violations.
    *If data was deleted, the data you pasted or imported doesn't match the field data types or the FieldSize property in the destination table.
    *If records were lost, either the records you pasted contain primary key values that already exist in the destination table, or they violate referential integrity rules for a relationship defined between tables.
    Do you want to proceed anyway?

    *****

    The same error as by wizard but I proceeded in the wizard and it imports, but by code doesn't import.

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    Perhaps you have fileds as Key fields (must have value), while in your exported file, it doesn't have

    Try to delete also the Relationship between the tables (if you have) and import it again

  5. #5
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    Yes I have one field as PK, but I cannot erase it, there must be one in the table.
    Also if I do it by code I must add a field in the table called "F1" otherwise is giving to me a runtime error saying that I don't have this field "F1" in the table. But if I add this field, there is no error but the import is not done and I still have the same error I posted before.

    The thing is nothing of that happens with the wizard and the import is done, with some conversion data problems, but it is done.

    Thanks for your help.

  6. #6
    Join Date
    Dec 2002
    Location
    Glasgow, UK
    Posts
    100
    could you post the CSV file and I could take a look at it?
    Access XP & WinXP Pro

  7. #7
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    I cannot attach the file, because dbforums doesn't accept the csv extension to upload a file. csv is not in the list of valid file extensions
    Attached Files Attached Files

  8. #8
    Join Date
    Dec 2002
    Location
    Glasgow, UK
    Posts
    100
    I managed to import the file fine but I had to create a custom import specification.

    To do this run the import wizard as normal then click on advanced, change the field "Artikelnr" to a text (it was recognising this as a date which then casued errors) then press "Save as" - it will give a name "Output import specification" then ammend your code to:

    DoCmd.TransferText acImportDelim, "output import specification", "DeliveryImport", "M:\Output.csv"

    and it shouldwork fine.

    good luck!
    Access XP & WinXP Pro

  9. #9
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Talking

    Thanks a lot, Xander,

    I didn't know how to make the import specification. Now I see the light, hehehe

    It's working perfectly.

Posting Permissions

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