Solved

Fixed Field Length

Posted on 1998-10-05
4
147 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

792 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