One field to auto fill another

Cpar

Registered User.
Local time
Today, 02:37
Joined
Jan 9, 2016
Messages
41
Hi everyone i am new to access. I am trying to build a custom form. I want to have a field called [Pressure range] change another field based on its value. For example if the pressure range is below 30,000 it would say one thing and it it was above 30,000 it would say another. How would i go about this?
 
In the event AfterUpdate for [Pressure range]. Don't use spaces in your control name.
Code:
Private Sub Pressure_range_AfterUpdate()
  If Me.Pressure_range < 30000 Then
    Me.AnotherControl = "Below"
  Else
    Me.AnotherControl = "Above"
  End If
End Sub
 
JHB thanks for your quick reply. Could you maybe break down the code for me and explain it. I would like to learn and i think that would help!
 
I think the code is self explaining - so what exactly do you not understand?
 
I guess I do not understand the me.anothercontrol= below. That kind of stuff
 
I am still stuck if someone else would like to help me!
 
Me.AnotherControl is just an example name. you will have to replaced it with the correct control name that you set on your form.
 
Rather than VBA it would be far simpler to use an expression as the ControlSource of the textbox that is to display the Above/Below.

Code:
= IIF([PressureRange]>30000, "Above", "Below")
 

Users who are viewing this thread

Back
Top Bottom