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

Output to a text file

Status
Not open for further replies.

neemi

Programmer
May 14, 2002
519
GB
I need to output certain fields to a text file using access 2002.

The fields that I need to output need to be on this text file at certain points. i.e. Ref number on the first line with the end character position of the field at character position 16.

The user name need to end at character position 42. Therefore if the username is 5 digits long it will begin at character position 37. If it is 10 digits long it will begin at character position 32. The important part is the character position's that the fields end at.

If I have not explianed very well let me know.

Can anyone advice.

I know I can use the Print command but I don't know how I can make sure I get the end character positions of the fields to be correct.

Cheers in advance.

Neemi
 
Neemi,

The thing to do is to create a string for each record that you want to output that has the text properly placed. For example, if Ref number is 6 digits long, then it needs to have 10 spaces placed in front of it.
Code:
For a = Len([Ref number]) To 15
    stringout = stringout & Chr(32)
Next a
stringout = stringout & refnum

This will place the last character of Ref number at position 16. Do likewise for any other that you need. Then just write the string to the text file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top