I have a form InventoryForm
and a table StockRecords
. I'm trying to get the records in the form to save to the table AfterUpdate
. Both my form and table have fields EmployeeName
, PartNo
, Quantity
, BinNo
, Supplier
, Shelf
, Description
, Price
& TargetStockLevel
.
The form AfterUpdate
's VBA code (that I've seen working for others online but not for me) is:
Private Sub Form_AfterUpdate()
CurrentDb.Execute "INSERT INTO StockRecord (EmployeeName, PartNo, Quantity, BinNo, Supplier, Shelf, Discription, Price, TargetStockLevel) VALUES ('" & Me.SelectName & "', '" & Me.PartNo & "', '" & Me.Quantity & "', '" & Me.BinNo & "', '" & Me.Supplier & "','" & Me.Shelf & "', '" & Me.Discription & "', '" & Me.Price & "', '" & Me.TargetStockLevel & "' )"
End Sub
Edit :
Private Sub Form_AfterUpdate()
'add data to table
CurrentDb.Execute "INSERT INTO StockRecord(EmployeeName, PartNo, Quantity, BinNo, Supplier, Shelf, Discription, Price, TargetStockLevel) " & _
" VALUES ('" & Me.cboSelectName & "', '" & Me.cboPartNo & "','" & _
Me.txtQuantity_Entered & "', '" & Me.txtBinNo & "', '" & Me.txtSupplier & "','" & Me.txtShelf & "', '" & Me.txtDiscription & "', '" & Me.txtPrice & "', '" & Me.txtTargetStockLevel & "' )"
End Sub
This new VBA code worked once but now won't (even when I made no changes). I get a message saying :
Compile Error : method or data member not found.
All fields are text boxes, except two combo boxes (SelectName
& PartNo
). How to fix this?