Solved Textbox Calculation, a question of conditional value

Anthony.DG

Registered User.
Local time
Today, 07:15
Joined
Oct 18, 2019
Messages
27
I have a form for calculating freight for an order with a textbox that works just fine. BUT my client says they want to implement a minimum freight charge of $80. (they deliver, dirt and gravel). So the client asks that if the calculation of the freight is less than 80 then they want the textbox to say $80. Now, I'm still fairly new to access but is this possible through a textbox? Or is this a deeper dive?
 
you can do that in a textbox. You make a calculated control and you can use the iif function
assume field is called "freightCharge". In the control source
=iif([freghtCharge] < 80,80,[freightCharge])
 
set the Default Value property of the [Freight Charge] to 80.
then add code to the Form's Before Update event:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Cancel = Nz(Me![Freight Charge], 0) < 80
If Cancel Then
    MsgBox "minimum Freight Charge is 80."
    With Me![Freight Charge]
        .SetFocus
        .Value = .DefaultValue
    End With
End If
End Sub
 
you can do that in a textbox. You make a calculated control and you can use the iif function
assume field is called "freightCharge". In the control source
=iif([freghtCharge] < 80,80,[freightCharge])
Thank you so much! Worked like a charm! :giggle:
 
set the Default Value property of the [Freight Charge] to 80.
then add code to the Form's Before Update event:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Cancel = Nz(Me![Freight Charge], 0) < 80
If Cancel Then
    MsgBox "minimum Freight Charge is 80."
    With Me![Freight Charge]
        .SetFocus
        .Value = .DefaultValue
    End With
End If
End Sub
Thank you I will try this out!
 

Users who are viewing this thread

Back
Top Bottom