E
EMILYTAN via AccessMonster.com
I am doing importing data from excel. My below code will add new part number
if there is no existing part number in the database and will update the
second field if there is part number exists in the database.
Code:
------------------------------------------------------------------------------
--
With rs For i = LBound(varArr1, 1) To UBound(varArr1, 1)
.Filter = "Part Number = '" & varArr1(i, 1) & "'"
If .EOF Then
.AddNew
.Fields(0).Value = varArr1(i, 1)
.Fields(1).Value = varArr1(i, 2)
Else: .Fields(1).Value = varArr1(i, 2)
End If
Next
.Update
.Close: Set rs = Nothing
------------------------------------------------------------------------------
--
So, my problem is, I just want to update the value of second field without
inserting new part number if i found there is new 1 in excel....
My this line works well .Fields(1).Value = varArr1(i, 2)..
Before that I tried to remove the .EOF and add new statement.
It works well when all the part number in the excel file exists in database
but when there is new part number it give me error...
if there is no existing part number in the database and will update the
second field if there is part number exists in the database.
Code:
------------------------------------------------------------------------------
--
With rs For i = LBound(varArr1, 1) To UBound(varArr1, 1)
.Filter = "Part Number = '" & varArr1(i, 1) & "'"
If .EOF Then
.AddNew
.Fields(0).Value = varArr1(i, 1)
.Fields(1).Value = varArr1(i, 2)
Else: .Fields(1).Value = varArr1(i, 2)
End If
Next
.Update
.Close: Set rs = Nothing
------------------------------------------------------------------------------
--
So, my problem is, I just want to update the value of second field without
inserting new part number if i found there is new 1 in excel....
My this line works well .Fields(1).Value = varArr1(i, 2)..
Before that I tried to remove the .EOF and add new statement.
It works well when all the part number in the excel file exists in database
but when there is new part number it give me error...