Solved

Creating a Fixed width Flat File from an rs

Posted on 1998-10-06
2
169 Views
Last Modified: 2010-04-30
Greetings,
I have just been assigned a little project which I haven't experinced yet and was looking for some ideas. I need to take some files (could be excel, csv etc) proabably import them to a db and from a recordset map them to a 200 column fixed witdth file, ie at 1-6 field A, 7-10 field B, 11-17 field C, etc.

Has anyone ever done this before? If so how do I code for the fixed width fields when creating an ASCII text file.

Thanks in advance.
BRad
0
Comment
Question by:bhummel
2 Comments
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1438401
When you will write to the output fixed file, you have to use the format fucntion :

sSQL = "Select * from yourTable"
set record = DB.Opnrecordset(sSQL, dbOpenDynaset)

Do while record.EOF = False
  sLine = Format(record("fieldA"), "@@@@@@")
  sLine = sLine & Format(record("fieldB"), "@@@")
  sLine = sLine & Format(record("fieldC"), "@@@@@@")
.

  ' *** Print to your file
  print #nFile, sLine

  record.MoveNext
loop
0
 

Author Comment

by:bhummel
ID: 1438402
Thanks I was trying to make this way to hard.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

813 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

14 Experts available now in Live!

Get 1:1 Help Now