Hello there,
So I have this button PN2001Btn that represents a product, this is inside a form POS where new orders are recorded. There is a subform called SalesDetailsSF which is Child6 inside the POS form creating the list of products that the new sale order will have. This button already fills a new record with the predetermined product and it also fills up the corresponding price.
What I need is that if that product was already there, then it sums the QTY up another number, but if it's not there then to continue adding a new record, I have tried a couple of things without success...
this is the code I have so far, but it only adds new records on each click, you can see the image of the form below so that you get an idea of what it is about (the button would be one of the bowls filling up the subform on the left, parent and child forms are connected by the SO
Code:
Private Sub PN2001Btn_Click()
Dim PCode As Integer
Dim LPrice As Variant
Dim PPrice As Variant
Dim ProdName As Variant
PCode = 2001
LPrice = DLookup("[PrecioL]", "[Precios]", "[PN]=" & PCode)
PPrice = DLookup("[PrecioP]", "[Precios]", "[PN]=" & PCode)
ProdName = DLookup("[Producto]", "[Products]", "[PN]=" & PCode)
Me.Child6.SetFocus
DoCmd.GoToRecord , , acNewRec
Me.Child6.Form.Producto = ProdName
If Me.SaleType = "Local" Then
Me.Child6.Form.Precio = LPrice
Else
Me.Child6.Form.Precio = PPrice
End If
End Sub