Chat with a LIVE Microsoft Access Expert!
 
       
 

         

   

Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
 
Chat with a LIVE Microsoft Access Expert!
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-20-2005, 01:53 PM
gajanank
Guest
 
Posts: n/a
File Parsing and Creating Error Report

1. I have a flat file (.txt) which I need to parse
C01121036200529400100000 0000000278
C10121036200529400100000 5500000001 010

basically file is of size 146 and has 4 different types of records namely C01,
C10,C20,C30.Only one C01 and C10 record while multiple C20,C30 records.
Each line contains one record.

2. Record structure of each record type is different.
3.Parse the .txt file,identify record type
4.Based on corresponding record structure apply validation rules
5.Generate error report where data violates validation rules.

can you please help me out to do this in best possible way.
Reply With Quote
Sponsored Links
  #2  
Old 11-21-2005, 06:05 AM
FoFa's Avatar
FoFa FoFa is offline
Registered User
 
Join Date: Jan 2003
Location: Texas, USA
Posts: 3,580
FoFa is on a distinguished road
I would say VBA. Create tables to hold the data and read the file with VBA and parse and validate on the fly.
BUT it can be done with queries by reading the text rows into a single text column table, then running queries against that to parse the data into separate tables and then run validation queries against those.
VBA is a better approach I think how ever.
__________________
E Pluribus Unum - Out of Many, One
Reply With Quote
  #3  
Old 11-21-2005, 07:40 AM
gajanank
Guest
 
Posts: n/a
Can you provide me sample code/function.

My goal is to build a small Access application ,

1. Which will alllow user to select a particular file
2. when user selects the file and click ok ok/parse button , system will parse the file and generate error report.

suppose my file has 4 different type of records , identified by record type filed. If I take first record , say c01 record , with sample data as
C01121036200529400100000 0000000278

then 121036 shows time
2005294 shows date (yyyyddd) (field type:char)
001 shows version number (field type:char)
000000 shows sequence number (field type:num)
0000000278 shows no of records in file. (field type:num)

char type fields should be checked as not null or spaces
while number field should be checked whether they contains number fields at all.

Once these basic checks are done there are some other business validation as well.

please elaborate the details with some sample code.

Txs
Reply With Quote
  #4  
Old 11-21-2005, 09:13 AM
FoFa's Avatar
FoFa FoFa is offline
Registered User
 
Join Date: Jan 2003
Location: Texas, USA
Posts: 3,580
FoFa is on a distinguished road
You could create 4 subs that process each kind of transaction. Then a simple:
Select CASE LEFT(MyRecord,3)
Case "C01" Call C01_process(Myrecord)
Case "C10" call C10_process(Myrecord)
Case "C20" call C20_process(Myrecord)
Case "C30" call C30_process(Myrecord)

Each routine will parse and validate each transaction type in this way. You just need somewhere to put it.
__________________
E Pluribus Unum - Out of Many, One
Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
parsing an imported field crgowo General 4 05-13-2003 07:26 AM


All times are GMT -8. The time now is 08:31 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) copyright 2009 Access World