I have fourteen text boxes on a form named "txtBox1", "txtBox2", "txtBox3", etc. I have another text box named "txtNumColumnsNeeded" into which the user types a number (1 to 14). Depending on what number is typed into "txtNumColumnsNeeded", I want to disable (Enabled = False) the text boxes coming after this number. For example - If the user types 3 into the text box, I want to disable "txtBox4", "txtBox5", "txtBox6", etc. through "txtBox14".
I know I could write code something like this:
If me.txtNumColumnsNeeded.value = 1 then
me.txtBox2.Enabled = false
me.txtBox3.Enabled = false
me.txtBox4.Enabled = false
etc., etc., etc., etc., etc.,
Endif
But there must be an easier (shorter) way. Can someone help?
I know I could write code something like this:
If me.txtNumColumnsNeeded.value = 1 then
me.txtBox2.Enabled = false
me.txtBox3.Enabled = false
me.txtBox4.Enabled = false
etc., etc., etc., etc., etc.,
Endif
But there must be an easier (shorter) way. Can someone help?