Sub ImportSomStuff()
On Error GoTo ImportSomStuff_Error
Dim rstImportSpec As DAO.Recordset, rstOutput As DAO.Recordset
Dim varImportSpec() As Variant
Dim intFileIn As Integer
Dim strBuffer As String
'Open the imposrt spec
[b]'***Change the SpecName below to your real filename[/b]
strBuffer = "SELECT FieldName, Start, Width " & _
"FROM MSysIMEXSpecs " & _
"INNER JOIN MSysIMEXColumns " & _
"ON MSysIMEXSpecs.SpecID = MSysIMEXColumns.SpecID " & _
"WHERE SpecName='[b]FileList Link Specification[/b]' " & _
"AND SkipColumn=False;"
Set rstImportSpec = CurrentDb.OpenRecordset(strBuffer)
'END 'Open the imposrt spec
'Open the output file
intFileIn = FreeFile
[b]'***Change the filename below to your real filename[/b]
Open "[b]C:\YourFIle.txt[/b]" For Input As #intFileIn
'END Open the output file
'Open the output recordset
Set rstOutput = CurrentDb.OpenRecordset("SELECT * FROM tblDestination;", dbOpenDynaset)
'Open the output recordset
'Loop through the input file
Do
Line Input #intFileIn, strBuffer
rstImportSpec.MoveFirst
'Create a new record in the output and loop through the spec
rstOutput.AddNew
Do
'Use the Mid() function and the import spec to parse the data
rstOutput.Fields(rstImportSpec.Fields("FieldName")) = _
Mid(strBuffer, rstImportSpec.Fields("Start"), rstImportSpec.Fields("Width"))
rstImportSpec.MoveNext
Loop Until rstImportSpec.EOF
rstOutput.Update
Loop Until EOF(intFileIn)
ImportSomStuff_Exit:
On Error Resume Next
rstImportSpec.Close
Set rstImportSpec = Nothing
rstOutput.Close
Set rstOutput = Nothing
Close #intFileIn
Exit Sub
ImportSomStuff_Error:
Stop
Resume ImportSomStuff_Exit
End Sub