Solved

Fixed Field Length

Posted on 1998-10-05
4
145 Views
Last Modified: 2010-04-30
I need to export data from Access into a text file in a cobol format.  This means that the field lengths need to be fixed for the record.  Field 1 must start in postition 1, field 2 in position 19, regardless of the amount of data in the field.  I've seen the text export wizard in Access, but that wont work, as every record takes three lines.  Any ideas?
0
Comment
Question by:JasonBurt
4 Comments
 
LVL 2

Expert Comment

by:vspeter
ID: 1438273
You've got the write script for this.

Cheers
0
 

Author Comment

by:JasonBurt
ID: 1438274
I'm sorry, I don't understand your comment.
0
 
LVL 3

Accepted Solution

by:
kfrick earned 100 total points
ID: 1438275
This code will format text to a fixed length:

Function PadText$(szData as string, intLength as integer)
  PadText$ = Left$(szData + Space$(intLength), intLength)
End Function

Do you know how to read from your database in code? Read each field you wish to export, then pass each one through this function to format it to the proper length, then write it to a text file.

like :
    szInputString=tblData![Field Name]
    szOutputString = PadText$(szInputString, 17)
    Print #1, szOutputString;

I can supply more code if you need more help....

Good luck!
-kf


0
 

Expert Comment

by:ashwin197816
ID: 20213556
i read the above solutions but can you please provide code for it?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now