Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Location
    St Pete, Fl
    Posts
    8

    Unanswered: Mulitple CSV file importing.

    I have mulitple files to import into Access. The file are in CSV format.

    Can some one please, provide me with some assistant in code this issue?

    I would like to import into one DB.

    Thanks
    Last edited by Kenbea; 09-02-03 at 17:44.

  2. #2
    Join Date
    Sep 2003
    Location
    UK
    Posts
    13
    Hi Kenbea

    you first need to define the ImportSpec from the File/Get External Data/Import menu option (click on Advanced). This defines the headings which you will be importing. Note - these need to match up exactly to the headings in your import table.

    Use the following Sub() which looks for all files within a specified subfolder of the current database directory

    Sub Import()

    Dim strFullDbPath as String
    Dim strImpPath as String
    Dim strImpFileNameExt as String

    strFullDbPath = CodeDb().Name 'find the current database path
    strImpPath = Left (strFullDbPath, Len (strFullDbPath) - Len (Dir(strFullDbPath))) &"SubFolderName\"
    strImpFileNeamExt = Dir(strImpPath &"*.csv")

    'Loop through all files in subfolder with extension *.csv

    While (strImpFileName <> "")
    Docmd.TransferText asImportDelim, strImportSpec, strTblName, strImpPath & strImpFileNameExt, 1
    strImpFileNameExt = Dir

    Wend

    End Sub


    You will need to declare and define variables strImportSpec and strTblName depending on your application.

    HTH

    Simon

  3. #3
    Join Date
    Sep 2003
    Location
    St Pete, Fl
    Posts
    8

    Multiple file access

    I will be using Access DB that will be new each time with two files with the 5 byte determining the type of file to go into one of two DBs.

    Looks like i will have to define two strings varibles?

    Thanks
    Kenbea


    Originally posted by sioma
    Hi Kenbea

    you first need to define the ImportSpec from the File/Get External Data/Import menu option (click on Advanced). This defines the headings which you will be importing. Note - these need to match up exactly to the headings in your import table.

    Use the following Sub() which looks for all files within a specified subfolder of the current database directory

    Sub Import()

    Dim strFullDbPath as String
    Dim strImpPath as String
    Dim strImpFileNameExt as String

    strFullDbPath = CodeDb().Name 'find the current database path
    strImpPath = Left (strFullDbPath, Len (strFullDbPath) - Len (Dir(strFullDbPath))) &"SubFolderName\"
    strImpFileNeamExt = Dir(strImpPath &"*.csv")

    'Loop through all files in subfolder with extension *.csv

    While (strImpFileName <> "")
    Docmd.TransferText asImportDelim, strImportSpec, strTblName, strImpPath & strImpFileNameExt, 1
    strImpFileNameExt = Dir

    Wend

    End Sub


    You will need to declare and define variables strImportSpec and strTblName depending on your application.

    HTH

    Simon

  4. #4
    Join Date
    Sep 2003
    Location
    St Pete, Fl
    Posts
    8

    Re: Multiple file access

    Originally posted by Kenbea
    I will be using Access DB that will be new each time with two files with the 5 byte determining the type of file to go into one of two DBs.

    Looks like i will have to define two strings varibles?

    Thanks
    Kenbea
    What if you have two input type of files? can it read the right 6 byte to determine this?

  5. #5
    Join Date
    Sep 2003
    Location
    St Pete, Fl
    Posts
    8

    Update to the CSV File Process

    I vahe 180 of two file with two layouts that needs to be imported into Access. before the .CSV extension the indicator of what type of file this is weather U file or an O type file. I would like to code this in Access to place eache type of file into the two database that will be created on the fly.

    Does anyone have code to process two type on multiple file of two types?

    Thanks
    Kenbea

  6. #6
    Join Date
    Sep 2003
    Location
    St Pete, Fl
    Posts
    8

    Update to the CSV File Process

    I vahe 180 of two file with two layouts that needs to be imported into Access. before the .CSV extension the indicator of what type of file this is weather U file or an O type file. I would like to code this in Access to place eache type of file into the two database that will be created on the fly.

    Does anyone have code to process two type on multiple file of two types?

    Thanks
    Kenbea

Posting Permissions

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