Excell Forms..textbox and Combobox to be initialized (1 Viewer)

asingh

Registered User.
Local time
Today, 15:28
Joined
Jul 14, 2005
Messages
20
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

Registered User.
Local time
Today, 04:58
Joined
Mar 25, 2002
Messages
516
If I understand correctly, this should give you an idea about how to loop through the tetxforms:

Code:
Sub TextInitialize(UF) 
Dim i as Long
    For i = 1 to 10
        UF.TextBox & i.Value = ""
    Next i
End Sub
________
2005 lexus cup history
 
Last edited:

asingh

Registered User.
Local time
Today, 15:28
Joined
Jul 14, 2005
Messages
20
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

New member
Local time
Today, 11:58
Joined
Dec 21, 2005
Messages
5
try me.controls (me refers to the main object, in this case your form)
 

asingh

Registered User.
Local time
Today, 15:28
Joined
Jul 14, 2005
Messages
20
me.controls is also not working..!!!!!!!!!!!
The text box is not being recognized as a control...!
 

Users who are viewing this thread

Top Bottom