473,466 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Delimited Text File Export

4 New Member
I am exporting a text file from Access that will be fed into a mainframe application (third party - not something I manage). The file contains a header record, body - which is the variable number of records to be imported into the mainframe, and a trailer record.

Upon export, Access automatically places a hard return after the trailer record - creating a new line after the trailer - albeit with no data on that line.

How can I create the text export to stop at the end of the last record and not insert a hard return creating that last line? Or, is there a routine I can add after the export to modify the file to remove that last "emty" line?
Aug 27 '08 #1
4 3596
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Sorry, I know of no way to stop the hard return at the end of the last line. Its use after the last line is entirely conventional for such text files.

If it is causing you a problem all I can suggest is that you write a custom text file reader in VB or VBA to read each text file line and output them all again, except for the last line which can be written without an end-of-line character. I have not googled to see if such a utility is already available on the web somewhere.

-Stewart
Aug 28 '08 #2
grumpydadtl
4 New Member
The last line (trailer) is always the number 9 - one digit, no return. Is there a routine I can write in VBA that will add the 9 without the return after the file is exported?
Aug 28 '08 #3
Stewart Ross
2,545 Recognized Expert Moderator Specialist
The VBA function below is very oldfashioned, but it works. It is used like this:

Expand|Select|Wrap|Line Numbers
  1. Call AddStopChar("C:Original FileName.txt", "C:Modified FileName.TXT)
Expand|Select|Wrap|Line Numbers
  1. Public Function AddStopChar(ByVal infilename As String, ByVal outfilename As String)
  2.     'Reads all lines from input file infilename then
  3.     'outputs the lines to output file outfilename
  4.     'and adds a single stop character to the end of the file
  5.     'without a newline character after
  6.     Dim strLine As String
  7.     Const stopchar = "9"
  8.     Open infilename For Input As #1
  9.     Open outfilename For Output As #2
  10.     Do While Not EOF(1)
  11.         Input #1, strLine
  12.         Print #2, strLine
  13.     Loop
  14.     Print #2, stopchar;
  15.     Close #1
  16.     Close #2
  17. End Function
There are other ways to concatenate files, but they tend to rely on shelling out to DOS and using the old Type command or the like to output all lines.

-Stewart
Aug 28 '08 #4
ADezii
8,834 Recognized Expert Expert
My Reply is almost exactly the same as Stewart's, sorry Stewart, but I'll post it anyway for reference purposes:
Expand|Select|Wrap|Line Numbers
  1. Dim strLine As String
  2.  
  3. '****************** Make your own substitutions here ******************
  4. Const conPATH_TO_EXPORTED_TXT_FILE As String = "C:\Test\Customers.txt"
  5. Const conNEW_FILE_NAME As String = "C:\Text Files\Demo\Customers_2.txt"
  6. '**********************************************************************
  7.  
  8. Open conPATH_TO_EXPORTED_TXT_FILE For Input As #1
  9. Open conNEW_FILE_NAME For Output As #2
  10.  
  11. Do While Not EOF(1)
  12.   Line Input #1, strLine
  13.   Print #2, strLine
  14. Loop
  15.   Print #2, "9"
  16.  
  17. Close #1
  18. Close #2
Aug 28 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Danny | last post by:
How do you create your own tab delimited ms access file. What is the TAB character and what is the NEWLINE character, also how to write to a text file Thanks in advance
1
by: sparks | last post by:
I have never done this and wanted to ask people who have what is the best way. One person said import it to excel, then import it into access table. but since this will be done a lot, I am...
1
by: nunYa | last post by:
I am trying to use the DoCmd.TransferText method to export an access table to a Tab Delimited Text File. I have put the code behind the onclick event of a button and keep getting the error...
5
by: Yama | last post by:
Hi, I am looking to create a report comma delimited on a click of a button. Explanantion: 1. Get from the database: "SELECT * FROM Customers WHERE Region = 'CA'" 2. Use either DataReader or...
2
by: David Lozzi | last post by:
Howdy, I need to export some data to tab delimited text file. I was hoping to simply convert my datagrid to it, but I can't seem to figure out how. Here's what I got in the page header. ...
1
by: Stella | last post by:
Help!!! Am extremely new to VBA. Want to set up code behind a button that will prompt the user for a table name(source of data) and file name(end result of export) and then export the data into a...
1
by: ZBV | last post by:
I have a date/time field which only contains the date. When I export the table to a tab-delimited file, the text file always contains not only the date but also the time (something like 09/22/20007...
1
by: bhapate1 | last post by:
Hi all, I Have a Table with 10 Columns, Among those i have Data in just 3 Columns. Rest of columns wil be blank. I want to Export that Table as a Pipe Delimited Text File. I am using...
4
by: Ted Theo | last post by:
hello cdma enthusiasts. long time no speak. i have an .adp which is connected to a sql 2k back end from which i need to export a table to a tab delimited text file. the export text wizard...
4
by: Uncle Scotty | last post by:
When I use the File -Export function in Access, all it seems to do is duplicate the file. It doesn't seem to offer conversion to delimited text files. Can someone tell me how to do that kind of...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.