I am using Access 2007.
I have a subform with a bound control (Control A) and it wants an input value from the user based on two other controls on the Main Form, (Control X and Control Y). The user can select either value or enter a third/different value!
The user now wants Control A to show or provide a default value based on the greater of Control X and Control Y.
I have inserted the following code into the On Load property of the main form,
Dim x
Dim y
x = [Forms]![MainForm]!ControlX.Value
y = [Forms]![MainForm]!ControlY.Value
If x>y then
[Forms]![MainForm]![SubformName]!ControlA.DefaultValue = x
else
[Forms]![MainForm]![SubformName]!ControlA.DefaultValue = y
endif
Endsub
I am very new to VBA so please bear with me. After I entered the code into the VBA screen I then clicked on the Debug. I did not receive any error messages.
I am not getting my desired results! What am I doing worng, or what am I not doing?
Any input would be greatly appreciated.
I have a subform with a bound control (Control A) and it wants an input value from the user based on two other controls on the Main Form, (Control X and Control Y). The user can select either value or enter a third/different value!
The user now wants Control A to show or provide a default value based on the greater of Control X and Control Y.
I have inserted the following code into the On Load property of the main form,
Dim x
Dim y
x = [Forms]![MainForm]!ControlX.Value
y = [Forms]![MainForm]!ControlY.Value
If x>y then
[Forms]![MainForm]![SubformName]!ControlA.DefaultValue = x
else
[Forms]![MainForm]![SubformName]!ControlA.DefaultValue = y
endif
Endsub
I am very new to VBA so please bear with me. After I entered the code into the VBA screen I then clicked on the Debug. I did not receive any error messages.
I am not getting my desired results! What am I doing worng, or what am I not doing?
Any input would be greatly appreciated.