Solved

Fixed Field Length

Posted on 1998-10-05
4
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

734 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