Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Import/Export Data

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 02-21-2009, 12:25 AM
Novice
 
Join Date: Feb 2009
Posts: 1
csvivek is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 12-07-2009, 10:49 AM
maurice maurice is offline Windows Vista Access 2003 (version 11.0)
Novice
 
Join Date: Dec 2009
Posts: 1
maurice is on a distinguished road
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
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -8. The time now is 02:48 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.