jto,
From what I can see there are a few problems with your data file. All this comes from the fact that you are using the SPLIT function and this function splits on EVERY SPACE, if two spaces are together it thinks that it has an empty data field in between those spaces, which is not true in your case.
The SubScript Out Of Range comes from your adjustment to the SPLIT function's peculiarities. You only have 16 data fields in your file, however all the empty spaces (data fields for SPLIT) boosts that count and so you can use Data(25) in your code. Here is the problem, when your code encounters the line
---------- ---------- ----------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------------------------
it no longer has 25 data fields, only 18, the last two spaces make the 2 extra fields, so now your code is causing errors, had I known that this was the actual data format I would not have suggested using SPLIT since it cannot handle this kind of data.
There is basically only one way to deal with this kind of data, creating a data definition and then 'manually' splitting the line using the Mid() function, like this:
Data definition (sorry about the reformatting by the web page):
Field Start Len
===========================
ACCOUNT_NO 1 10
MOBILE_NO 11 10
BILL_REF_NO 23 11
OTC 35 10
RC 46 10
USAGE 57 10
MISC 68 10
ADJ 79 10
DISC 90 10
ST 101 10
BILLED_AMT 112 10
LATE_FEE 123 10
PAYMENT 134 10
PREV_BAL 145 10
AMT_DUE NAME 156 30
Splitting code:
Data(0) = Left(InLine, 10) 'Or Mid(InLine, 1, 10)
Data(1) = Mid(InLine, 11, 10)
Data(2) = Mid(InLine, 23, 11)
.
.
.
Data(15) = Right(InLine, 32) 'Or Mid(InLine, 156)
This also changes the definition of the array from Data() to Data(15), otherwise VB will not know how many elements the array should have. You could also define it as Data(1 to 16) and modify your code accordingly, either way is the same it's only a question of preference and habit of working with 0-based or 1-based arrays.
The second problem, of not updating more than 3 items, arises from the definition of the table and the empty data fields in your input data. All the fields in the table have the property Allow Zero Length set to No so when you try to add a field that contains a zero length string the table rejects it. The solution is simple, change the definition of your table to allow for zero length strings.
I have NOT tested these solutions but I am confident that they will solve your problems.
Happy coding
Yomet