help looping through textboxs on userform

F

funkymonkUK

hi

I have a userform which has labels,comboboxes, textboxes and
commandbutton.

I have 10 textboxes which are names from textbox1 through to textbox10
is there a way to loop through these. What I want to do is when the
user clicks cancel button it will clear all the values which they have
entered in to textbox 1-10 and then hide the userform.

i tried something like this

'For Each Item In frmmanualentry.Controls '.Item
'
'Item.Value = ""

'Next Item

the problem is it does through all the comboboxes,labels and anythign
on the userform and changes them to blank values.
 
I

Ivan Raiminius

Hi,

you can add into your loop check for textbox

For Each Item In frmmanualentry.Controls
if item.name like "textbox*" then
item.value = ""
end if
next item

Regards,
Ivan
 
F

funkymonkUK

thanks for the suggestion i tried that but when i step through the code
and I move my mouse over the word Item on the line "FOR each ...." item
is coming up as the value of the textbox,combobox,label etc. so it does
not seem to register it and clear the value.
 
F

funkymonkUK

Thank Nigel.:eek:


I think I should KICK myself right now. I see where I was going wrong I
forgot although the it was a textbox the control had a name which was
textbox if the textbox.name was cat then i would have had top have
"cat" & i




thanks man
 

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