Import CSV file in Access VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • teneesh
    New Member
    • Mar 2007
    • 46

    Import CSV file in Access VBA

    I'd like to do an import but not sure how to do it with a CSV file.
    this would be my line of code when using an xlsx file, but how do i do it with a CSV?
    DoCmd.TransferS preadsheet acImport, acSpreadsheetTy peExcel9, "tbl_stats" , "S:\ Go To Sleep\Import Data Code\Actiwatch sample.xlsx", True



    Thank you!
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Originally posted by teneesh
    I'd like to do an import but not sure how to do it with a CSV file.
    this would be my line of code when using an xlsx file, but how do i do it with a CSV?
    DoCmd.TransferS preadsheet acImport, acSpreadsheetTy peExcel9, "tbl_stats" , "S:\ Go To Sleep\Import Data Code\Actiwatch sample.xlsx", True



    Thank you!
    DoCmd.TransferT ext acImportDelim, "<specifica tion name>", "tbl_stats" , "S:\ Go To Sleep\Import Data Code\Actiwatch sample.xlsx", True

    To get a specification name you must first manually import the file and using the advanced wizard save the specification. Otherwise just leave it blank. The true at the end assumes you have field names in the first line of your csv file. If not change it to false.

    Comment

    Working...