Solved Textbox Calculation, a question of conditional value (1 Viewer)

Anthony.DG

Registered User.
Local time
Today, 05:17
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?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 08:17
Joined
May 21, 2018
Messages
8,529
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])
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:17
Joined
May 7, 2009
Messages
19,245
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
 

Anthony.DG

Registered User.
Local time
Today, 05:17
Joined
Oct 18, 2019
Messages
27
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:
 

Anthony.DG

Registered User.
Local time
Today, 05:17
Joined
Oct 18, 2019
Messages
27
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

Top Bottom