View Full Version : Excell Forms..textbox and Combobox to be initialized


asingh
12-12-2005, 09:10 AM
Hi......
I have a form in MS - Excell which has 5 textbox's (txtbox1, txtbox2..etc) and 2 combobox's (cmbox1,cmbox2). What I want is that when the form is loaded (the frm activate event) all the txtbox's be initialized to blank, and the combobox's also be initialized. I dont want to do this by typing the line : -- frmMain.txtbox1.value = "" for each of the txt box. Is there any For LOOP which can help me do this..i.e it will read all the txtbox controls on my form and intialize them all to " ".



thanks

asingh

shades
12-12-2005, 09:55 AM
If I understand correctly, this should give you an idea about how to loop through the tetxforms:


Sub TextInitialize(UF)
Dim i as Long
For i = 1 to 10
UF.TextBox & i.Value = ""
Next i
End Sub

asingh
12-16-2005, 06:49 AM
I tried the above mentioned and it is not working. It gives a compike error where the ampersand sign is placed...!!

I now tried the following code:

'///start of code
Dim TxtBxtoFnd as Control

For Each TxtBxtoFnd in frmMain.Controls

if TypeOf TxtBxtoFnd is textbox then
MsgBox "Text Box found on Form"
end if

Next TxtBxtoFnd



'///end of code

This code is giving no compile error...but it is never recognizing [i.e it never goes to the msgbox line] when a text box is found.

Pieter
12-21-2005, 10:46 AM
try me.controls (me refers to the main object, in this case your form)

asingh
12-22-2005, 07:28 AM
me.controls is also not working..!!!!!!!!!!!
The text box is not being recognized as a control...!