weightinwildcat
Programmer
I am working on code for a form button to add a new record to a table. I have tried two approaches.
The first approach is:
Set rs2 = db.OpenRecordset("SELECT OrderNumber, OrderID, ProductID, ShipNumber, " & _
"ShipQty, DateShipped, Notes " & _
"FROM ShipPartial", dbOpenDynaset)
rs2.AddNew
rs2!OrderNumber = SONumber
rs2!OrderID = OrderID
rs2!ProductID = ProdID
rs2!ShipNumber = QtyOrdered
rs2!ShipQty = QtyOrdered
rs2!DateShipped = DateShipped
rs2!Notes = Notes
rs2.Update
rs2.Close
Set rs2 = Nothing
The second approach is:
strSQLShipPartial = "INSERT INTO ShipPartial (OrderNumber,OrderID," & _
"ProductID,ShipNumber,ShipQty,DateShipped,Notes) " & _
"VALUES (" & SONumber & "," & OrderID & "," & Chr(39) & ProductID & Chr(39) & "," & _
QtyOrdered & "," & QtyToShip & "," & Chr(35) & DateShipped & Chr(35) & "," & _
Chr(39) & Notes & Chr(39) & ")"
In both cases, in addition to adding a record the way that I want, I also am left with an additional record that has its own autonumber ID, an entry in the OrderID field, and an entry in the DateShipped field. This is causing problems with the display in my subform. Any thoughts as to what is causing it and how to work around it?
The first approach is:
Set rs2 = db.OpenRecordset("SELECT OrderNumber, OrderID, ProductID, ShipNumber, " & _
"ShipQty, DateShipped, Notes " & _
"FROM ShipPartial", dbOpenDynaset)
rs2.AddNew
rs2!OrderNumber = SONumber
rs2!OrderID = OrderID
rs2!ProductID = ProdID
rs2!ShipNumber = QtyOrdered
rs2!ShipQty = QtyOrdered
rs2!DateShipped = DateShipped
rs2!Notes = Notes
rs2.Update
rs2.Close
Set rs2 = Nothing
The second approach is:
strSQLShipPartial = "INSERT INTO ShipPartial (OrderNumber,OrderID," & _
"ProductID,ShipNumber,ShipQty,DateShipped,Notes) " & _
"VALUES (" & SONumber & "," & OrderID & "," & Chr(39) & ProductID & Chr(39) & "," & _
QtyOrdered & "," & QtyToShip & "," & Chr(35) & DateShipped & Chr(35) & "," & _
Chr(39) & Notes & Chr(39) & ")"
In both cases, in addition to adding a record the way that I want, I also am left with an additional record that has its own autonumber ID, an entry in the OrderID field, and an entry in the DateShipped field. This is causing problems with the display in my subform. Any thoughts as to what is causing it and how to work around it?