Hi good day guys.. i am doing a POS in Microsoft access for my thesis.. the problem .. i create a button and i want to enter a data to the list box.. if you click the menu button it will automatically add the item on list box.. and i also have the table of my product it include the product name, price and quantity..thanks for you're help

Dani AI

Generated

For : with a Products table that already holds product name, price and stock, the most robust pattern for a POS is to write the cart to a small "Cart" table and bind the listbox to a query that joins Cart -> Products (showing name, qty, unit price and line total). This supports stock checks, totals, persistence and easier printing/checkout. A quick-and-dirty alternative is ListBox.AddItem, but AddItem only works when RowSourceType = "Value List" and does not persist to a table, so it is not recommended for a real sales flow.

Example VBA (form code) to insert-or-update a Cart row and refresh a bound listbox:

Sub AddToCart(productID As Long, qty As Integer)
    Dim db As DAO.Database
    Dim unitPrice As Currency
    Dim sql As String

    Set db = CurrentDb
    unitPrice = Nz(DLookup("Price", "Products", "ProductID=" & productID), 0)
    If unitPrice = 0 Then Exit Sub

    If Nz(DLookup("Qty", "Cart", "ProductID=" & productID), 0) = 0 Then
        sql = "INSERT INTO Cart (ProductID, Qty, UnitPrice) VALUES (" & productID & ", " & qty & ", " & unitPrice & ")"
    Else
        sql = "UPDATE Cart SET Qty = Qty + " & qty & " WHERE ProductID = " & productID
    End If

    db.Execute sql, dbFailOnError
    Me.lstCart.Requery
End Sub

Troubleshooting / practical tips: bind the listbox with a SELECT that calculates line totals and filters by a SessionID for multi-user carts; requery the listbox after any insert/update; check stock before adding and decrement Products.Quantity only at checkout; prefer a split front-end/back-end or a server DB for multiple terminals. 's external pointer may offer additional examples; ignore unhelpful commentary such as and focus on the Cart-table approach for a stable POS.

Recommended Answers

All 2 Replies

Member Avatar for Member #120589

Was going to respond but it's probably a waste of time if this question has been sown all over the interweb. Note to OP - stop wasting people's time by posting the same thing in multiple forums. You are now offically on peoples' shit-list.

commented: For those that need to know. Super High Intensity Training List. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.