• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 154
  • Last Modified:

Fixed Field Length

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
JasonBurt
Asked:
JasonBurt
1 Solution
 
vspeterCommented:
You've got the write script for this.

Cheers
0
 
JasonBurtAuthor Commented:
I'm sorry, I don't understand your comment.
0
 
kfrickCommented:
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
 
ashwin197816Commented:
i read the above solutions but can you please provide code for it?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now