dbTalk Databases Forums  

Importing MS Office Excel Comma Separated Values Files into a MSAccess 2003 database

comp.databases.ms-access comp.databases.ms-access


Discuss Importing MS Office Excel Comma Separated Values Files into a MSAccess 2003 database in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
zufie
 
Posts: n/a

Default Importing MS Office Excel Comma Separated Values Files into a MSAccess 2003 database - 05-14-2010 , 01:45 PM







Reply With Quote
  #2  
Old   
Rich P
 
Posts: n/a

Default Re: Importing MS Office Excel Comma Separated Values Files into a MS Access 2003 database - 05-14-2010 , 02:14 PM






Greetings,

It sounds like what you have is a .cvs file. If this is the case then
you can write a routine using the Open (textfile) function and Line
Input to read in the lines. Or, if coding isn't your thing, you can
search for VBA scripts that can read comma delimited (.csv) files and
implement that into your project. Here is a sample that might work for
you:

Sub ReadCSVfile()
Dim s As String, RS As DAO.Recordset
Set RS = CurrentDb.OpenRecordset("tblText")
Open "C:\1A\test1.csv" For Input As #1
Do While Not EOF(1)
Line Input #1, s
RS.AddNew
RS(0) = s
RS.Update
Debug.Print s
Loop
Close #1
RS.Close
End Sub

This routine reads each line of a .csv file and writes it to a table
("tblText") which only contains one field -- a memo field (incase the
lines contain a lot of text).

The next step is then to parse out each field of data which would be
delimited by commas. You can use the Split function for this.

Sub SplitString1()
Dim str1 As String, str2 As Variant, str3 As Variant
str1 = "a,b,c,d"
str2 = Split(str1, ",")
For Each str3 In str2
Debug.Print str3
Next
End Sub

Then you would write the contents of each line to a 2nd table that would
contain the same number of fields at the source data.

HTH


Rich

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #3  
Old   
Salad
 
Posts: n/a

Default Re: Importing MS Office Excel Comma Separated Values Files into aMS Access 2003 database - 05-14-2010 , 02:17 PM




Reply With Quote
Reply




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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.