Solved

Fixed Field Length

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

707 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

12 Experts available now in Live!

Get 1:1 Help Now