raziel3
Registered User.
- Local time
- Today, 13:04
- Joined
- Oct 5, 2017
- Messages
- 316
I'm in a little bind here. I have a Price table setup
I'm using this function to get the current price
On my Sales form (a query is the record source), the user enters the Sales Date, UPC, Quantity, and the Price field is automatically filled.
The problem I'm having is, I have a field called Extended that gives the total cost by Quantity * Price so if the customer buys 2 Cookies the Total changes to $4.00 but I don't want it to total the amount when 12 or 24 Beer is bought. The Price for that quantity of Beer is already set. As it is the Extended price for 12 Beer is coming up to $1,020. Any advice on how to get around that?
EFFDATE | UPC (this is numeric, text field is shown) | QUANTITY | PRICE |
1/1/20 | BEER | 1 | $10.00 |
1/1/20 | BEER | 12 | $85.00 |
1/1/20 | BEER | 24 | $170.00 |
1/1/20 | Cookies | 1 | $2.00 |
I'm using this function to get the current price
Code:
Public Function GetPrice(inpUPC As Double, inpQuantity As Double, inpDate As Date) As Double
On Error Resume Next
Dim strPrice As Double
Dim strMaxDate As Date
inpDate = Format(inpDate, "m/d/yyyy")
strMaxDate = DMax("EFFDATE", "Prices", "UPC= " & inpUPC & " AND EFFDATE<= # " & inpDate & " #")
strPrice = DLookup("Price", "Prices", "UPC= " & inpUPC & " And [EFFDATE] = #" & strMaxDate & "# And Quantity= " & inpQuantity & " ")
GetPrice = strPrice
End Function
On my Sales form (a query is the record source), the user enters the Sales Date, UPC, Quantity, and the Price field is automatically filled.
The problem I'm having is, I have a field called Extended that gives the total cost by Quantity * Price so if the customer buys 2 Cookies the Total changes to $4.00 but I don't want it to total the amount when 12 or 24 Beer is bought. The Price for that quantity of Beer is already set. As it is the Extended price for 12 Beer is coming up to $1,020. Any advice on how to get around that?