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

Access - Changing Value of Field Based on Value of Other Field

Status
Not open for further replies.

bowfonz

IS-IT--Management
Jul 13, 2004
52
0
0
US
This may be the easiest problem ever, just can't seem to get it.

I have a Form called Orders.
In that form I have a couple text boxes, SubTotal and Shipping.
I want to change the value of the Shipping box depending on what the value of the SubTotal box is.

The way I'm trying to do it is in the OnChange event of the SubTotal box I have the following VB code:

Code:
Private Sub SubTotal_Change()
If Me!SubTotal < 100 Then
    Me!Shipping = 5
Else
    Me!Shipping = 6.5
End If
End Sub

It seems like a pretty common and simple thing to do but it just doesn't seem to work. I've tried several different version of the above but none of them worked.
I'm new to Access and only have a rudimentary programming knowledge, so that's why I'm having trouble here.

Thanks,
Tom

 
Hi bowfonz,

You really don't need to use code for this. Set the ControlSource of Shipping to:
[blue][tt]=IIf([SubTotal]<100,5,6.5)[/tt][/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
If the Shipping box is bound, then you may consider the BeforeUpdate event procedure of the Orders form:
Me!Shipping = IIf(Me!SubTotal < 100, 5, 6.5)

You have to know that the Change and xxxUpdate events of a textbox are NOT triggered when value is changed by code.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks guys! That worked great.
I knew there had to be an easy way to do something as simple as that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top