Hi there,
I have a text file (flat file) which I would like to import on a
regular basis into Access. The text file contains 2 record types,
header (prefixed with RHD) and detail (prefixed with RDT). Each
recordtype has a unique structure.
-------------------------------------------------------------------------------
For example line one might read:
RHD123456ABCDEF
Characters 1-3 is record type, characters 4-9 is field X, characters
4-15 is field Y
-------------------------------------------------------------------------------
Line 2 onwards are detail records for line 1:
RDT999ABC99
Characters 1-3 is record type, characters 4-6 is field X, characters
7-9 is field Y, characters 10-11 is field Z.
-------------------------------------------------------------------------------
Is it possible to interrogate each line of the file to determine the
recordtype and subsequently import the fields into a table using a
predefined record structure?
I am looking for a solution which will work along the following lines:
1. Check folder for interface file
2. Read file line x
3. Determine recordtype (RHD or RDT)
4. If recordtype is RHD then save each field (X,Y) in associated
variables
5. If recordtype is RDT then import to table using RHD variables and
RDT fields.
6. After successful import move file to "completed" folder
I have had experience importing deliminated files but never attempted
to import multiple record types in a single file.
I hope this makes sense.
Any help/advice will be much appreciated.
Regards,
Nathan