How to create comma seperated value text file from an access table 
Author Message
 How to create comma seperated value text file from an access table

Hi

I am fairly new to VB.

I have a desktop application that creates an access table.
I need to take the data from that table and create a comma seperated text
file.

Please Help.
Any Tutorials, suggestions, comments will be greatly appreciated.

thanks
LT



Wed, 20 Apr 2005 00:19:42 GMT  
 How to create comma seperated value text file from an access table
NO PROBLEM

Open App.Path & "\" & Tablename & ".csv" For Output As #1

Rs.MoveFirst

Dim MyCSV As String

For X = 0 To Rs.Fields.Count - 1
MyCSV = MyCSV & Chr$(34) & Rs.Fields(X).Name & Chr$(34) & ","
Next X

Print #1, MyCSV
MyCSV = ""

Do While Not Rs.EOF
For X = 0 To Rs.Fields.Count - 1
MyCSV = MyCSV & Chr$(34) & Rs.Fields(X).Value & Chr$(34) & ","
Next X
Print #1, MyCSV
MyCSV = ""
Rs.MoveNext
Loop
Close #1


Quote:
> Hi

> I am fairly new to VB.

> I have a desktop application that creates an access table.
> I need to take the data from that table and create a comma seperated text
> file.

> Please Help.
> Any Tutorials, suggestions, comments will be greatly appreciated.

> thanks
> LT



Wed, 20 Apr 2005 01:17:59 GMT  
 How to create comma seperated value text file from an access table
use WRITE method

--
--
Cedric Cheah



Quote:
> Hi

> I am fairly new to VB.

> I have a desktop application that creates an access table.
> I need to take the data from that table and create a comma seperated text
> file.

> Please Help.
> Any Tutorials, suggestions, comments will be greatly appreciated.

> thanks
> LT



Wed, 20 Apr 2005 09:35:33 GMT  
 How to create comma seperated value text file from an access table
Loran,

Just addition to postings. Another way to do that is to open ADO recordset,
based on your SELECT statement. Then save opened recordset into XML stream
and apply XSL stylesheet to transform data into sepoarated text. Then save
stream into file

--
Val Mazur
Microsoft MVP


Quote:
> Hi

> I am fairly new to VB.

> I have a desktop application that creates an access table.
> I need to take the data from that table and create a comma seperated text
> file.

> Please Help.
> Any Tutorials, suggestions, comments will be greatly appreciated.

> thanks
> LT



Wed, 20 Apr 2005 08:49:50 GMT  
 How to create comma seperated value text file from an access table

Hi

I am fairly new to VB.

I have a desktop application that creates an access table.
I need to take the data from that table and create a comma seperated text
file.

Please Help.
Any Tutorials, suggestions, comments will be greatly appreciated.

No problem:

Sub ExportAccessToTextADO()

Dim cnn As New ADODB.Connection
Dim sqlString As String

cnn.Open _
   "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                     "Data Source=d:\My Documents\DB1.mdb;" & _
                     "Jet OLEDB:Engine Type=4;"

'New file
sqlString = "SELECT * INTO [Text;DATABASE=d:\My Documents\TextFiles].[Plot.txt] FROM [tblPlot]"
'Existing file
'sqlString = "INSERT INTO [Text;DATABASE=d:\My Documents\TextFiles].[Plot.txt] SELECT * FROM
[tblPlot]"

cnn.Execute sqlString

End Sub

Please note that by default the first row of the text file will be the table column names. If you
don't want those you need to create a schema.ini file with the ColNameHeader=False spec.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc...


Microsoft MVP (Visual Basic)



Fri, 22 Apr 2005 22:16:06 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Reading a comma delimited text file and inserting the values into SQL Server table

2. importing comma seperated values (csv)

3. Comma Seperated Values

4. HELP:Datagrid editing on comma-seperated files.

5. Reading non comma seperated data from a file.

6. Comma delimited text file to DB table using ADO

7. Creating a text file without commas & quotes

8. Reading text file to create Access table

9. Creating Tables in Access 2000 using SQL Text files

10. Create a Linked table to external text file in Access

11. Import comma delimited file into Access table

12. using isam text driver to open comma delimited text file

 

 
Powered by phpBB® Forum Software