I have a fixed width text file looks like this:
gl0340.txt
01061 ASSETS - BANKS
---------------------------
001-999999-02 FIRST NATL BANK
103001 MTR 3JUN02 INTEREST MAY2002 555.55
00593 ASSETS - MORE BANKS
------------------------------------
001-888888-01 SECOND NATL BANK
103002 MTR 3JUN02 INTEREST MAY2002 666.66
1. I wrote the code to read this file into memory one line at a time
2. Trying to use the select case construct - to create variables
3. At the point where the select drops out of the loop append the variables to a table, which should look thus:
ACOD CNUM MDATE SDATE INTEREST
1061 999999 3JUN02 MAY2002 555.55
0593 888888 3JUN02 MAY2002 666.66
4. Code written thus far:
Public Sub Text()
Dim strLine As String
Dim w_acod, w_actitle As String
Dim wvar1, wvar2 As Long
Open "C:\dbproject\gl0340.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strLine
wvar1 = Val(Mid(strLine, 2, 4))
wvar2 = Val(Mid(strLine, 7, 6))
wvar3 = Val(Mid(strLine, 5, 6))
Select Case wvar1
Case Is > 1
w_acod = Mid(strLine, 2, 4)
End Select
Select Case wvar2
Case Is > 100
w_cnum = Mid(strLine, 7, 6)
End Select
Select Case wvar3
Case Is > 100
w_mdate = Mid(strLine, 25, 6)
End Select
Loop
Close #1
End Sub
5. I'm new to Access VBA and not sure if the Select Case can be written more efficiently. And now that i have my variables how do I append them to a blank new table?
Any help / comment would be appreciated.
Sinyce
gl0340.txt
01061 ASSETS - BANKS
---------------------------
001-999999-02 FIRST NATL BANK
103001 MTR 3JUN02 INTEREST MAY2002 555.55
00593 ASSETS - MORE BANKS
------------------------------------
001-888888-01 SECOND NATL BANK
103002 MTR 3JUN02 INTEREST MAY2002 666.66
1. I wrote the code to read this file into memory one line at a time
2. Trying to use the select case construct - to create variables
3. At the point where the select drops out of the loop append the variables to a table, which should look thus:
ACOD CNUM MDATE SDATE INTEREST
1061 999999 3JUN02 MAY2002 555.55
0593 888888 3JUN02 MAY2002 666.66
4. Code written thus far:
Public Sub Text()
Dim strLine As String
Dim w_acod, w_actitle As String
Dim wvar1, wvar2 As Long
Open "C:\dbproject\gl0340.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strLine
wvar1 = Val(Mid(strLine, 2, 4))
wvar2 = Val(Mid(strLine, 7, 6))
wvar3 = Val(Mid(strLine, 5, 6))
Select Case wvar1
Case Is > 1
w_acod = Mid(strLine, 2, 4)
End Select
Select Case wvar2
Case Is > 100
w_cnum = Mid(strLine, 7, 6)
End Select
Select Case wvar3
Case Is > 100
w_mdate = Mid(strLine, 25, 6)
End Select
Loop
Close #1
End Sub
5. I'm new to Access VBA and not sure if the Select Case can be written more efficiently. And now that i have my variables how do I append them to a blank new table?
Any help / comment would be appreciated.
Sinyce