Sub readuparow()
' put your own error trappping here
' reference DAO 3.6 library
' nb if you have a partnumber without a supplier in the
' list - ensure supplier field in the table has the property
' Zero Length String set to YES or you will get an error
Dim mynumber As Integer
Dim currId As String
Dim currstring As String
Dim dataArray()
Dim spacepos As Integer
Dim mystring As String
Dim mydb As Database
Dim myrs As DAO.Recordset
Set mydb = CurrentDb()
Set myrs = mydb.OpenRecordset("Suppliers", dbOpenDynaset)
Dim LineNum As Integer
Dim x As Integer
'place full path to your text file here
Open "e:\development\tecforum\suppliers.txt" For Input As #1 ' Open file for input.
LineNum = 1 'this is your array index
'This reads the data into a single column array
'ready for manipulation
Do Until EOF(1) ' Loop until end of file.
ReDim Preserve dataArray(LineNum) 'keeps data but resizes array
Input #1, mystring 'Read data into two variables.
dataArray(LineNum) = mystring
LineNum = LineNum + 1
Loop
'_________________________________________________
'the following for next loop can be deleted
' its so you can get a view of the data
For x = 1 To LineNum - 1
Debug.Print x, dataArray(x) 'Original State
Next
'_________________________________________________
Close #1 ' Close file.
'Data is now read into your array ,ready to manipulate
'and write to your table
'
'Initalise the table
'if you want to overwrite not append
'then remove the else option leaving the end if
If myrs.EOF = -1 And myrs.BOF = -1 Then
myrs.AddNew
myrs.Update
myrs.MoveFirst
Else
myrs.AddNew
myrs.Update
myrs.MoveLast
End If
'Process the array data into the table
'without headers
For x = 2 To LineNum - 1
currId = Left$(dataArray(x), InStr(dataArray(x), " "

) 'chks for space delimeter
If currId = "" And Not IsNull(dataArray(x)) Then currId = dataArray(x)
'Gets nxt rec supplier name
If x + 1 <= LineNum - 1 Then
mystring = dataArray(x + 1)
Else
mystring = ""
End If
currstring = Mid$(mystring, InStr(mystring, " "

+ 1)
'Brings the two together (currId) & (currstring)
'omitting blank records completely
'Write to destination table
If Not IsNull(currId) And Not IsNull(mystring) Then
With myrs
.Edit
!P_n = currId
!Supplier = currstring
.Update
If x < LineNum - 1 Then
.AddNew
.Update
.MoveNext
End If
End With
Else
End If
Next
End Sub