Solved

Creating a Fixed width Flat File from an rs

Posted on 1998-10-06
2
168 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

932 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

11 Experts available now in Live!

Get 1:1 Help Now