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

Conditional Expression on a form

Status
Not open for further replies.

voltarei

Technical User
Oct 25, 2006
40
GB
Hi All,
I have a form that is used to take card payments, and I would like it to calculate the charge amount based on the type of card used.

The fields on the form are:
Card type - combo box
Net amount
Charge
Total amount

I thought I could use an IF expression to say that "If the card type is Visa Credit, then multiply the net amount field by 0.015 and display the result in the charge field, otherwise display a 0.
My inexperience in this type of expression means that although I understand the logic, I am unable to produce the written code.

Can anyone offer any help?

Thanks
Phil
 
You should have a field in your ChargeCardType table that stores the multiplier. Then create this public function in the form's module:
Code:
Public Function CalcNet()
If Not IsNull(Me.[Card Type]) AND Not IsNull(Me.[Net Amount]) Then
    Me.Charge = Me.[Card Type].Column(1) * Me.[Net Amount]
End If
You can then set the After Update event properties of the Card Type and Net Amount controls.


Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top