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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Statement Help

Status
Not open for further replies.

liloandstitch

Technical User
Mar 29, 2003
7
AU
Hi,
I've designed a form which has a few field in it, three of which are Sale Price, Discount and Discount type. A user will enter the sale price, Discount type ("F" for a dollar discount or "P" for a percentage discount), and also enter the actual discount. I need a field in the form which will calculate the actual price based on these fields. I've tried doing an if statement but i keep getting errors. Can anyone PLEASE help??
Thanks
 
Try this...you'll have to change the names of the textboxes to be your names...

If you want the example give me an e-mail adress and I will send it to you...

rivate Sub cmdCal_Click()
If IsNull(Me.txtDisc) Then
MsgBox "You must enter a Number", vbOKOnly, "Enter Discount Cost"
Else
Select Case Me.txtType
Case Is = "F"
Me.txtCost = Me.ActualCost - Me.txtDisc
Case Is = "P"
Me.txtCost = Me.ActualCost - (Me.ActualCost * (Me.txtDisc / 100))
End Select
End If


End Sub

 
I don't want to do this via vb, rather then an if statement in the control source. This is basically what I have now, but it doesn't seem to be working...

=IIf([DiscountType]=[P],[NEW PRICE]=[SalePrice]-[Discount],[NEW PRICE]=[SalePrice]*([Discount]/100))

What I'm trying to say is if discount type equals p, then new price will equal sale price minus discount, else the new price will equal sale price times the discount. When I go to the form the field just comes out with #Name?

Any ideas?
 
=IIf([DiscountType]=[P],[NEW PRICE]=[SalePrice]-[Discount],[NEW PRICE]=[SalePrice]*([Discount]/100))

All you need is:

=IIf([DiscountType]=[P],[SalePrice]-[Discount],[SalePrice]*([Discount]/100))

"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Tried your new formula, although when i go to the form it still comes up with #name?

Still not sure what's wrong but I definitely appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top