Trying to LOOP thru txt boxes

D

David

I seem to be full of questions today... I have 48 text boxes titled txt1 thru
txt 48. I am trying to set enabled = False on them without typing 48 lines
of code. This code gives me the error, invalid qualifier on the
"temp_text.Enabled = False".
I have tried the function LockBoundControls I found referenced in this
newsgroup, but it seems a bit too advanced for me.

Is there a way to loop thru these 48 controls without writing 48 lines of
code?


intcount = 0
Do While intcount <= 48
intcount = intcount + 1
temp_text = "me.txt" & intcount
temp_text.Enabled = False

Next

As always, you guys and gals ROCK!!!!!
 
D

Douglas J. Steele

intcount = 0
Do While intcount <= 48
intcount = intcount + 1
Me.Controls("txt" & intcount).Enabled = False
Loop

or

Dim ctlCurr As Control

intcount = 0
For intcount = 1 To 48
Me.Controls("txt" & intcount).Enabled = False
Next intcount
 
D

David

Douglas,... PERFECT, thank you. Seems I tried to combine several techniques
into one mess.
I did set the intcount = 1 right off the bat and then reordered the intcount
+ 1 line to after the enabled = false line.
 
D

Douglas J. Steele

Yeah, I just noticed that the first loop will go to txt49. Shouldn't have
just copied your code! <g>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top