Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

export to TXT file only one column in a table

Status
Not open for further replies.

sarahjane28

IS-IT--Management
Oct 23, 2002
14
0
0
US
HELP>>>>>>>>>>>>>>>>>>>>>>>

Please?


I need to know if anyone has been able to export only one column of of a table (sql backend) to a txt file THROUGH CODE.

Basically I need my user to press a button and send a only one column to a csv file but it need to allow more than 8000 characters.

Please help - anyone?
I will be forever grateful,


Thanks
Sarah Jane

 
Not sure about the over 8000 char thing, but you can export a query that has only one column intead of the table itself.

Just a thought.



ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
How do you get the 8000 characters?... is this the output of all records in the table being combined to make one large record for the text file... If so, you can loop through the table, capture the value in the field, store it to a variable, continue to append the data in the field to the variable as you loop through it, then you can use OPEN and PRINT to output the data...

This example uses DAO to capture the data in Field "Artist" from Table "tblGroups", pad it to a length of 100 then store it to a variable "strOut". Then it creates a file in the "C:\" root directory named "Groups.txt" and sends a message when complete.

Dim db As DAO.Database, rst As DAO.Recordset
Dim strOut As String
Set db = CurrentDb
Set rst = db.OpenRecordset("tblGroups")
With rst
.MoveFirst
Do While Not .EOF
strOut = strOut & Trim(rst!Artist) & String(100 - Len(Trim(Artist)), Chr(32))
.MoveNext
Loop
End With
Open "c:\Groups.txt" For Output As #1
Print #1, strOut
Close #1
MsgBox "Done"

If this isn't close to what you're looking for, then plese provide additional info.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top