I have inserted 4 columns (barcode, name, quantity and price).
When I scan any particular barcode for the 2nd time I don't want the data duplicated, just the quantity increased.
So far I have just coded
Private Sub CTbarcode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Main.MSAadodc1.Recordset.Find "BARCODE='" & CTbarcode.Text & "'", , adSearchForward, 1
If Not Main.MSAadodc1.Recordset.EOF Then
CAadodc1.Recordset.Find "BARCODE='" & CTbarcode.Text & "'", , adSearchForward, 1
If CAadodc1.Recordset.EOF Then
CTproduct.Text = Main.MSAadodc1.Recordset!PRODUCT
CTprice.Text = Main.MSAadodc1.Recordset!PRICE
CTquantity.Text = "1"
CAadodc1.Recordset.AddNew
CAadodc1.Recordset!tbarcode = CTbarcode.Text
CAadodc1.Recordset!tproduct = CTproduct.Text
CAadodc1.Recordset!tquantity = CTquantity.Text
CAadodc1.Recordset!tprice = CTprice.Text
CAadodc1.Recordset!tdiscount = CTquantity.Text
CAadodc1.Recordset!ttotalprice = Val(CTprice.Text * CTquantity.Text) - CTquantity.Text
CTbarcode.SetFocus
Else
CAadodc1.Recordset!tquantity = Val(CAadodc1.Recordset!tquantity + 1)
CTbarcode.SetFocus
CAadodc1.Refresh
End If
Else
MsgBox "Data Not Found!", vbOKOnly + vbCritical, "Unknown!"
CTbarcode.Text = ""
End If
End If
End Sub
Private Sub CTbarcode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Main.MSAadodc1.Recordset.Find "BARCODE='" & CTbarcode.Text & "'", , adSearchForward, 1
If Not Main.MSAadodc1.Recordset.EOF Then
CAadodc1.Recordset.Find "tbarcode='" & CTbarcode.Text & "'", , adSearchForward, 1
If CAadodc1.Recordset.EOF Then
CTproduct.Text = Main.MSAadodc1.Recordset!PRODUCT
CTprice.Text = Main.MSAadodc1.Recordset!PRICE
CTquantity.Text = "1"
CAadodc1.Recordset.AddNew
CAadodc1.Recordset!tbarcode = CTbarcode.Text
CAadodc1.Recordset!tproduct = CTproduct.Text
CAadodc1.Recordset!tquantity = CTquantity.Text
CAadodc1.Recordset!tprice = CTprice.Text
CAadodc1.Recordset!tdiscount = 0
CAadodc1.Recordset!ttotalprice = Val(CTprice.Text * CTquantity.Text) - CTquantity.Text
CTbarcode.SetFocus
CTbarcode.Text = ""
CTprice.Text = ""
CTproduct.Text = ""
CTquantity.Text = ""
Else
CAadodc1.Recordset!tquantity = CAadodc1.Recordset!tquantity + 1
CAadodc1.Recordset!tdiscount = 0
CAadodc1.Recordset!ttotalprice = Val(CAadodc1.Recordset!tprice * CAadodc1.Recordset!tquantity - CAadodc1.Recordset!tdiscount)
CAadodc1.Recordset.Update
CTbarcode.SetFocus
CTbarcode.Text = ""
CTprice.Text = ""
CTproduct.Text = ""
CTquantity.Text = ""
End If
Else
MsgBox "Data Not Found!", vbOKOnly + vbCritical, "Unknown!"
CTbarcode.Text = ""
End If
End If
End Sub