Reading text (.txt) files from with Microsoft Access

The following is sample VBA code for reading a text file from within Microsoft Access.  Note that this is but a few lines of a five hundred line routine of importing a file which has about fifteen different types of lines.

Dim Alpha1 As Variant, Alpha2 As Variant, Alpha3 As Variant
Dim Alpha4 As Variant, Alpha5 As Variant, Alpha6 As Variant
Dim Numeric1 As Variant, Numeric2 As Variant, Numeric3 As Variant
Dim Numeric4 As Variant, Numeric5 As Variant, Numeric6 As Variant
Dim strInputFileName As String

Open strInputFileName For Input As #1
Do While Not EOF(1) ' Loop until end of file.

    ' Acorn, Isometric, Isometric Revision, Spool, Acorn Revision ,PipeSpec
    Input #1, Alpha1, Alpha2, Alpha3, Alpha4, Numeric5, Alpha6
    ' do something with fields

    ' Dia-Ins, Weight, ?, Spool Drawer Initials, Date, ?
    Input #1, Numeric1, Numeric2, Numeric3, Alpha4, Alpha5, Numeric6
    ' do something with fields again


Close #1

 [ Access | Main ]