Gina,
See below.
Regards,
Nikos
Nikos .... wow ... I was struggeling around and around and in the meantime
used that split func as well.
somehow it works .... but not correctly
your code- on the other hand - looks extremely good to me
I wonder whether the rst:Update is a real update of a recordset (most
presumably not) in case a record has been edited and a part. field should
just be updated.
My code actually adds a new record; don't let rst.Update confuse you, it
is not the same as in Update vs. Append query, it just means "save" the
current record in the recordset, regardless of whether in was a new one
or just an edited existing one.
therefore I do these 2 db.Execute strSQL_Upd & strSQL_Ins, dbFailOnError =
False
even if it is bad style it should work anyhow ?!? ...
I see now what you are trying to do. Hadn't realized that before. You
can still do it through a recordset operation like:
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM tbl_MaterialList")
Open "YourFile" For Input As #1
Do While Not EOF(1)
Line Input #1, line
arWords = Split(line, vbTab)
mat = arWords(0)
use= arWords(1)
If use= "" Then use= mat
price= arWords(2)
If IsNull(price) Then price= 0 'no quotes for a currency field!
rst.FindFirst "Material = '" & mat & "'"
If rst.NoMatch Then
rst.Addnew
rst.Fields("Material") = mat
Else
rst.Edit
EndIf
rst.Fields("Use") = use
rst.Fields("Price") = price
rst.Update
Loop
rst.Close
set rst = Nothing
Set db = Nothing
Your approach should work fine but less efficiently, as it is like
opening two recordsets for each line imported.