Export data from .csv file into ms access using access vba

Hi,
I have need to create vba code in access to export .csv files from selected folder into  ms access table using ms access vba.

Wilol apreciate any help
Thanks,
Maksim
maximyshkaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IrogSintaCommented:
I'm assuming you mean Import a CSV file into an Access table.  The simplest way for you to do it would be to create a Saved Import (if you have Access 2007/2010/2013).  Just click Text File in the Import section of the External Data tab of the ribbon.  When you complete the import wizard it will ask you if you want to save the import steps.  This Saved Import will now be listed as  a task you could run whenever you click Saved Imports in the Import section of the External Data tab.

You can call this Saved Import from code using this line:
DoCmd.RunSavedImportExport "Name Of Your Saved Import"

Ron

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ramesh VCommented:
Hi,
Please try the code below:

Sub Import_CSV_File()
Dim myPath As String, myFile As String
Dim FldrPicker As FileDialog
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
    With FldrPicker
        .Title = "Select A Target Folder"
        .AllowMultiSelect = False
        If .Show <> -1 Then GoTo NextCode
        myPath = .SelectedItems(1) & "\"
    End With
NextCode:
    myPath = myPath
    If myPath = "" Then Exit Sub
    myExtension = "*.csv"
    myFile = Dir(myPath & myExtension)
    Do While myFile <> ""
        DoCmd.TransferText acImportDelim, , "Test", myPath & myFile, True
        myFile = Dir()
    Loop
End Sub

1st create the table and change it in the code as per your need. Here my table name is "Test"
This will loop the selected folder and imports all the CSV files into the same table [Test]
Ramesh VCommented:
Hi Maksim,
Did you get time to test the code I posted.
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.