Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to give my customers a disco 1

Status
Not open for further replies.

robmkimmons

Technical User
Jun 29, 2001
51
US
I want to give my customers a discount when they purchase more. I have a pricing structure where after $800.00 they get 5% off of their purchase.
This is easily calculated with the following function in the unbound text box [Discount] on Form.frmOrders

=IIf([Subtotal]>800,0.05,0)

The problem I have is twofold: One, I want to add another discount of 10% if their purchase subtotal reaches $1,500.00. And two, I want to be able to personally override the discount amount if I choose to (eg. If they are at $1,499.00 I want to go ahead and give them the 10% discount).

My theory is to make the [Discount] text box bound to Table.tblOrders and use Else IF coding to determine the discount amount. I tried testing my theory with only one IF statement first to make sure I put the code under the correct event and it didn’t work. Is the code correct and just under the wrong event? Or is the coding wrong too? Any suggestions? Below is the coding I used.

Private Sub Subtotal_Change()

Dim DiscountAmount As Double

If Me![Subtotal] > 800 Then

DiscountAmount = 0.05

Else: DiscountAmount = 0

End If

Me.Discount = DiscountAmount

End Sub

Much thanks!


~Rob

If we expect the unexpected, does that make the unexpected... well, expected?
 
Rob,


The following will handle the discount calculation.

=IIf([Subtotal]>800 And [Subtotal]<1500,0.05,IIf([Subtotal]>1500,0.1,0))

Then add another field for additional discount that will allow you to enter any additional discount value that you would like.

Finally, have one last field for total discount that will have it control source be =[Discount]+[AdditionalDiscount]


Hope this helps,

Steve
 
Just in addition to what steve said,

I think prolly the reason the code you used isnt working is since you need to set it to requery after the subtotal field updates

so in the afterupdate event of your subtotal field (or wherever the unbound text box is pulling info from) put

[unbound textbox name].requery


also just noticed, you dont have .value after the field names

so discountamount.value = 0.05


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top