I have dat files that require looking at the first 3 characters of each line to determine the specname to use & the table they will tranfer into. Previous programmer ran transfertext multiple times (each specname & table) creating huge overgrown tables. I have temp added a cleanup function to reduce them to only their required records. There has to be a smarter way.
I want to:
Dim strLine 'As Variant
Dim strType As String
Open "c:\data\MyFiles.dat" For Input As #1
'Read first line into a variable
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, strLine ' Read line into variable.
Debug.Print strLine ' Print to the Immediate window.
strType = Left$(strLine, 3)
Debug.Print strType
'Select Case strLine
If strType = "XYZ" Then
Debug.Print "Importing " & strLine
DoCmd.TransferText acImportFixed, "nmcdatafixed", "Imported NMC Data", _
strLine, False
However, Access will not allow the use of a vaiable (strLine) in the transfertext command, it must be a file. Won't that put the entire file into the table?
If I read it into a temp file with 2 fields, the first being 3 characters & the 2d 300 (max) and then import using the mid$ command, would require a lot of coding.
Any sugggestions?
Larry
I want to:
Dim strLine 'As Variant
Dim strType As String
Open "c:\data\MyFiles.dat" For Input As #1
'Read first line into a variable
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, strLine ' Read line into variable.
Debug.Print strLine ' Print to the Immediate window.
strType = Left$(strLine, 3)
Debug.Print strType
'Select Case strLine
If strType = "XYZ" Then
Debug.Print "Importing " & strLine
DoCmd.TransferText acImportFixed, "nmcdatafixed", "Imported NMC Data", _
strLine, False
However, Access will not allow the use of a vaiable (strLine) in the transfertext command, it must be a file. Won't that put the entire file into the table?
If I read it into a temp file with 2 fields, the first being 3 characters & the 2d 300 (max) and then import using the mid$ command, would require a lot of coding.
Any sugggestions?
Larry