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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print records in clolumnar mode

Status
Not open for further replies.

2009luca

Programmer
Jul 27, 2013
222
IT
I need to export in a txt file a recordset from access and ado, in columnar mode, with the head of names of records
How to?

Similar the format of attached txt.

NOTE:
each records have the max lenght 25 characters
Linkhttp://files.engineering.com/getfile.aspx?folder=0f73a1e5-a467-4fff-8eb6-90f9d183a8d3&file=Documento.zip
 
Your file looks like this:

[pre]
F1 F2 F3 ... FN
AAAAA BBBBBBBB CCCCCCCCCCCCC DDDDD
AAAAA BBBBBB CC DDDDD
AAAAA BBBBBBBBBBBB CCCCCCCCCCCCC DDDDD
...
AAAAA B CCCCCCCCCCCCC D
[/pre]

Is that supposed to be a fixed-length text file?
And look like this?

[pre]
F1 F2 F3 ... FN
AAAAA BBBBBBBB CCCCCCCCCCCCC DDDDD
AAAAA BBBBBB CC DDDDD
AAAAA BBBBBBBBBBBB CCCCCCCCCCCCC DDDDD
...
AAAAA B CCCCCCCCCCCCC D
[/pre]



Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Text files have no formatting, and even tab stops are subject to interpretation by whatever program reads the file. So all you can do is "format" by selectively adding blank spaces within lines.

In VB6 you can do this via native text I/O using the Tab() pseudo-function within Print # statements. This is covered in the documentation.
 
This is actually not that difficult to do:
Add a Reference to Microsoft ActiveX Data Objects X.X Library
Make a connection to your Access data base
Create an ADODB recordset
Open your text file for output
Loop thru recordset’s fields names ([tt]rst.Fields(x).Name[/tt]) - fill it with Spaces
Write it into your text file
Loop thru records in your recordset and for every record:
---Loop thru all fields ([tt]rst.Fields(x).Value[/tt]) - fill it with Spaces
---Write it into your text file
Close your text file.
UR Done.

The “fill it with Spaces” you can use [tt]rst.Fields(x).DefinedSize[/tt] to get the width of every field in your recordset.


Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top