Hi
I have two tables: [Products] and [TempData]. [Products] has some extra fields which [TempData] does not have. While [TempData] contains some new records and updated fields, which I imported from MS Excel 2000.
How can I update all the [Products] records with the [TempData] records, while retaining the extra fields in [Products]? I basically want the number of records in [Products] to be the same as the number of records in [TempData], but retain the extra fields that [Products] has.
Please help.
Below is what I currently am trying to play with.
==========
I have two tables: [Products] and [TempData]. [Products] has some extra fields which [TempData] does not have. While [TempData] contains some new records and updated fields, which I imported from MS Excel 2000.
How can I update all the [Products] records with the [TempData] records, while retaining the extra fields in [Products]? I basically want the number of records in [Products] to be the same as the number of records in [TempData], but retain the extra fields that [Products] has.
Please help.
Below is what I currently am trying to play with.
==========
Code:
Private Sub Update_table()
Dim ProdNum As Field
Dim db As Database
Dim rsDb As DAO.Recordset
Set db = CurrentDb
Set rsDb = db.OpenRecordset("Products", dbOpenDynaset)
' Need lots of help from here
rsDb.MoveFirst
Set ProdNum = rsDb.Fields("ProductNumber")
Do While Not rsDb.EOF '???
If ProdNum.Value Like [TempData]!F1 Then '???
With rsDb
.Edit
.Fields("ProductNumber").Value = [TempData]!F1
.Fields("Description").Value = [TempData]!F2
.Fields("Meas").Value = [TempData]!F3
.Fields("Fraction").Value = [TempData]!F4
.Fields("WHC").Value = [TempData]!F5
.Fields("Dept").Value = [TempData]!F6
.Fields("Bin").Value = [TempData]!F7
.Fields("Tax").Value = [TempData]!F8
.Fields("SalePrice").Value = [TempData]!F9
.Update
End With
Else
With rsDb
.AddNew
.Fields("ProductNumber").Value = [TempData]!F1
.Fields("Description").Value = [TempData]!F2
.Fields("Meas").Value = [TempData]!F3
.Fields("Fraction").Value = [TempData]!F4
.Fields("WHC").Value = [TempData]!F5
.Fields("Dept").Value = [TempData]!F6
.Fields("Bin").Value = [TempData]!F7
.Fields("Tax").Value = [TempData]!F8
.Fields("SalePrice").Value = [TempData]!F9
.Update
End With
End If
Loop
MsgBox "All Product have been updated."
End Sub