Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / March 2007

Tip: Looking for answers? Try searching our database.

Automated Importing CSV into Access - NO LINKS

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
simplymidori - 27 Mar 2007 21:54 GMT
Hello,

I'm looking to see if someone can tell me how to write a module that
will import csv files into a table.

The file names ALL have the word containing  TRKR and they are labeled
differently.

Currently, I download csv, save in a folder, prep csv files for
manually importing into access.

Any suggestions?

Thanks Simplymidori
Tom Wickerath - 31 Mar 2007 09:38 GMT
Hi Simplymidori,

Use the TransferText method. Here is an example:

Private Sub cmdImportCSVTextFile_Click()
On Error GoTo ProcError

DoCmd.TransferText _
         TransferType:=acImportDelim,
SpecificationName:="CompanyDelimited", _
         Tablename:="YourTableNameHere", _
         Filename:="CompletePathToYourFile.txt", _
         HasFieldNames:=True

MsgBox "Company details imported from a" & vbCrLf _
       & "comma separated value (CSV) text file"

ExitProc:
  Exit Sub
ProcError:
  MsgBox "Error: " & Err.Number & ". " & Err.Description
  Resume ExitProc
End Sub

For simplicity, I'm showing a hard-coded path above for the FileName
parameter. There are various ways of supplying the complete file path
dynamically. One method involves a little API code to invoke the Common File
Dialog. If all of your files were in one directory, you could set up a loop
and use the Dir function to determine the complete path of each file.

Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

> Hello,
>
[quoted text clipped - 10 lines]
>
> Thanks Simplymidori
Tom Wickerath - 31 Mar 2007 09:40 GMT
Hi Simplymidori,

Use the TransferText method. Here is an example:

Private Sub cmdImportCSVTextFile_Click()
On Error GoTo ProcError

DoCmd.TransferText _
         TransferType:=acImportDelim,
SpecificationName:="CompanyDelimited", _
         Tablename:="YourTableNameHere", _
         Filename:="CompletePathToYourFile.txt", _
         HasFieldNames:=True

MsgBox "Company details imported from a" & vbCrLf _
       & "comma separated value (CSV) text file"

ExitProc:
  Exit Sub
ProcError:
  MsgBox "Error: " & Err.Number & ". " & Err.Description
  Resume ExitProc
End Sub

For simplicity, I'm showing a hard-coded path above for the FileName
parameter. There are various ways of supplying the complete file path
dynamically. One method involves a little API code to invoke the Common File
Dialog. If all of your files were in one directory, you could set up a loop
and use the Dir function to determine the complete path of each file.

Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

> Hello,
>
[quoted text clipped - 10 lines]
>
> Thanks Simplymidori
Tom Wickerath - 31 Mar 2007 09:40 GMT
Hi Simplymidori,

Use the TransferText method. Here is an example:

Private Sub cmdImportCSVTextFile_Click()
On Error GoTo ProcError

DoCmd.TransferText _
         TransferType:=acImportDelim,
SpecificationName:="CompanyDelimited", _
         Tablename:="YourTableNameHere", _
         Filename:="CompletePathToYourFile.txt", _
         HasFieldNames:=True

MsgBox "Company details imported from a" & vbCrLf _
       & "comma separated value (CSV) text file"

ExitProc:
  Exit Sub
ProcError:
  MsgBox "Error: " & Err.Number & ". " & Err.Description
  Resume ExitProc
End Sub

For simplicity, I'm showing a hard-coded path above for the FileName
parameter. There are various ways of supplying the complete file path
dynamically. One method involves a little API code to invoke the Common File
Dialog. If all of your files were in one directory, you could set up a loop
and use the Dir function to determine the complete path of each file.

Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

> Hello,
>
[quoted text clipped - 10 lines]
>
> Thanks Simplymidori
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.