Originally Posted by
orange
When you change discounts on Product prices, you may be changing information of existing invoices and Sales.
OMG , i didn't think about that before !! .
Actually i wrote a piece of code that loops through the table and whatever product is check (True) with the checkbox only change it's price , And it works fine but as i said before it changes the products price based on the first product price !
Code:
Dim sql_text As String
Dim NewValue As Double
Dim ItemValue As Double
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Products")
MsgBox "Are you sure you want to make discount "& me.discountValue.value & " % On these products ? ", vbInformation, "Easy Cash V. 1.0"
Do Until rst.EOF
ItemValue = DLookup("PRD_Price", "Products", "Check = -1")
NewValue = (ItemValue - (Me.discountValue.value / 100) * ItemValue)
sql_text = "UPDATE Products " & _
"SET PRD_Price= " & Round(NewValue, 1) & _
" WHERE Check = " & -1 & ""
DoCmd.RunSQL (sql_text)
rst.MoveNext
Loop
rst.Close
DoCmd.RefreshRecord