Disable text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a form with a few text boxes on it. There is a set of two text boxes
that need to be enabled/disabled depending on what the user enters. I would
like to have them both enabled when the user enters the form. As soon as the
user enters data into on text box, I would like to disable the other text box
and vice versa. if they enter data in the other text box then disable the
first one. How can I do this?

Thanks!
 
Set the enabled properties of both in design view. Then in the After Update
events of each:
For text1:
Me.text2.Enabled = False
And for text2:
Me.text1.Enabled = False
 
Create a function in the form

Function EnableTextBox()
Me.[TextBox1].Enabled = IsNull(Me.[TextBox2]) Or Me.[TextBox2] = ""
Me.[TextBox2].Enabled = IsNull(Me.[TextBox1]) Or Me.[TextBox1]=""
End Function

Call this function from three events
1. OnCurrent event of the form
2. After Update event of TextBox1
3. After Update event of TextBox2
 
That worked! Thank you so much!

Ofer said:
Create a function in the form

Function EnableTextBox()
Me.[TextBox1].Enabled = IsNull(Me.[TextBox2]) Or Me.[TextBox2] = ""
Me.[TextBox2].Enabled = IsNull(Me.[TextBox1]) Or Me.[TextBox1]=""
End Function

Call this function from three events
1. OnCurrent event of the form
2. After Update event of TextBox1
3. After Update event of TextBox2
--
\\// Live Long and Prosper \\//
BS"D


jped said:
Hello,

I have a form with a few text boxes on it. There is a set of two text boxes
that need to be enabled/disabled depending on what the user enters. I would
like to have them both enabled when the user enters the form. As soon as the
user enters data into on text box, I would like to disable the other text box
and vice versa. if they enter data in the other text box then disable the
first one. How can I do this?

Thanks!
 
Your welcome, Glad I could help

--
\\// Live Long and Prosper \\//
BS"D


jped said:
That worked! Thank you so much!

Ofer said:
Create a function in the form

Function EnableTextBox()
Me.[TextBox1].Enabled = IsNull(Me.[TextBox2]) Or Me.[TextBox2] = ""
Me.[TextBox2].Enabled = IsNull(Me.[TextBox1]) Or Me.[TextBox1]=""
End Function

Call this function from three events
1. OnCurrent event of the form
2. After Update event of TextBox1
3. After Update event of TextBox2
--
\\// Live Long and Prosper \\//
BS"D


jped said:
Hello,

I have a form with a few text boxes on it. There is a set of two text boxes
that need to be enabled/disabled depending on what the user enters. I would
like to have them both enabled when the user enters the form. As soon as the
user enters data into on text box, I would like to disable the other text box
and vice versa. if they enter data in the other text box then disable the
first one. How can I do this?

Thanks!
 
Back
Top