Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Macro To Import CSV to ACCESS

    Hello there,


    I have a macro to import multiple csv files to acess.
    but when i do this with the code attached it doesnt work. the import process creates a lot of error tables which has errors like "Unparsable Record", "Field Truncated" and etc..
    Code:
    Function Importcsv()
    
    Dim fs, fldr, fls, fl
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    
    Set fldr = fs.getfolder("E:\Data As It Is\Conf\ImportGenius_murrali2\To Vishnu\")
    
    Set fls = fldr.files
    
    For Each fl In fls
     
        If Right(fl.Name, 4) = ".csv" Then
        DoCmd.TransferText acImportDelim, , "M1", "E:\Data As It Is\Conf\ImportGenius_murrali2\To Vishnu\" & fl.Name, True
        End If
     
    Next fl
    
    End Function
    But the same file when imported with the access file wizard which is opened by right clicking on the main area doesnt create any error table.

    what might be the problem in my code.

    Thanks in Advance.

    --
    Regards,
    Vivek Palanissamy

  2. #2
    maurice is offline Novice
    Windows Vista Access 2003
    Join Date
    Dec 2009
    Posts
    1

    Lightbulb try this code

    Sub importDossier(ByVal strDossier As String)

    If Dir(strDossier, vbDirectory) = "" Then
    MsgBox "not found !", vbExclamation
    Exit Sub
    End If

    strFichier = Dir(strDossier)
    While strFichier <> ""
    Debug.Print strFichier
    DoCmd.TransferText acImportDelim, ";", strFichier, strDossier & strFichier, True, ""
    strFichier = Dir
    Wend
    End Sub

    Raafat Maurice Aziz

Please reply to this thread with any new information or opinions.

Similar Threads

  1. error in macro
    By nawaray in forum Access
    Replies: 0
    Last Post: 02-10-2009, 12:06 PM
  2. Import large txt into access
    By klm127 in forum Import/Export Data
    Replies: 0
    Last Post: 04-23-2007, 06:22 AM
  3. Import Lotus Notes address book into a MS Access table.
    By acheo in forum Import/Export Data
    Replies: 0
    Last Post: 02-19-2007, 02:43 PM
  4. import an excell spreadsheet in an access database
    By lmichaud in forum Import/Export Data
    Replies: 0
    Last Post: 11-03-2006, 08:29 AM
  5. Unable to import or link tables through odbc in Access SP2
    By Dave Jenkins in forum Import/Export Data
    Replies: 3
    Last Post: 11-09-2005, 11:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums