Requiring field based another fields answer

  • Thread starter Thread starter timglass via AccessMonster.com
  • Start date Start date
T

timglass via AccessMonster.com

I have a field in a form that I only want a user to input information in if
another field is not null. Does anyone know how?
 
The easiest way is to use conditional formatting (Format - Conditional
Formatting) and use "expression is". In the condition put something
similar to "[Form]![control] is null" So, when it is null, the other
field should be disabled.
 
Lets call the field you only want to allow input if the other field is not
null txtBox2, and the other field txtBox1.
Set the Locked property of txtBox2 to Yes in design view.
Then in the After Update event of txtBox1:

Me.txtBox2.Locked = IsNull(Me.txtBox1)

The same line of code should go in the form's Current event so it will
affect existing records:

If Not Me.NewRecord Then
Me.txtBox2.Locked = IsNull(Me.txtBox1)
End If
 
thanks i tried this and get an error that it can't find the me macro. did I
miss something?

Thanks in advance for you help
 
Where are you trying to do this? Me is not a macro, it is a reference to the
current form.
If frmAnyForm is the current form, then
Me.MyText box
would be the same as
Forms!frmAnyForm!MyTextbox
 
i put it in the on update line as you suggested and I get that error. I then
change me to the actual form name zand still get the same error
thanks i tried this and get an error that it can't find the me macro. did I
miss something?

Thanks in advance for you help
Lets call the field you only want to allow input if the other field is not
null txtBox2, and the other field txtBox1.
[quoted text clipped - 12 lines]
 
I am not sure you are putting it in the correct place.
Open the form in design view
Select the text box
Select Properties
Select the Events tab
Select the After Update event
Click on the command button to the right with the 3 dots on it
Select Code Builder
The VBA editor will appear
Put the code in here and change then names to match your controls.

timglass via AccessMonster.com said:
i put it in the on update line as you suggested and I get that error. I then
change me to the actual form name zand still get the same error
thanks i tried this and get an error that it can't find the me macro. did I
miss something?

Thanks in advance for you help
Lets call the field you only want to allow input if the other field is not
null txtBox2, and the other field txtBox1.
[quoted text clipped - 12 lines]
I have a field in a form that I only want a user to input information in if
another field is not null. Does anyone know how?
 
Back
Top