Resetting userform controls en mass 
Author Message
 Resetting userform controls en mass

I'm looking for an efficient means of resetting a userform's controls to
default values for use in a userform's Activate event.  In the case at hand,
the control types are known so I could specify the types in the code.

This doesn't work, but it should be clear from it what it is I want to do.
What changes would you suggest to get it working?

    Dim ctl As MSForms.Control

    For Each ctl In Controls
        If ctl.Type = TextBox Then
            ctl.Value = ""
        ElseIf ctl.Type = CheckBox Then
            ctl.Value = False
        End If
        . . .
    Next ctl

Thanks,

Alder



Sun, 14 Aug 2005 04:42:53 GMT  
 Resetting userform controls en mass
This is one of the ways to do it

     For Each ctl In Controls
         If TypeName(ctl) = "TextBox" Then
             ctl.Value = ""
         ElseIf TypeName(ctl) = CheckBox Then
             ctl.Value = False
         End If
     Next ctl

Krgrds,
Perry



Quote:
> I'm looking for an efficient means of resetting a userform's controls to
> default values for use in a userform's Activate event.  In the case at
hand,
> the control types are known so I could specify the types in the code.

> This doesn't work, but it should be clear from it what it is I want to do.
> What changes would you suggest to get it working?

>     Dim ctl As MSForms.Control

>     For Each ctl In Controls
>         If ctl.Type = TextBox Then
>             ctl.Value = ""
>         ElseIf ctl.Type = CheckBox Then
>             ctl.Value = False
>         End If
>         . . .
>     Next ctl

> Thanks,

> Alder



Sun, 14 Aug 2005 04:51:15 GMT  
 Resetting userform controls en mass
Quote:
>          ElseIf TypeName(ctl) = CheckBox Then

Should read

          ElseIf TypeName(ctl) = "CheckBox" Then



Quote:
> This is one of the ways to do it

>      For Each ctl In Controls
>          If TypeName(ctl) = "TextBox" Then
>              ctl.Value = ""
>          ElseIf TypeName(ctl) = CheckBox Then
>              ctl.Value = False
>          End If
>      Next ctl

> Krgrds,
> Perry



> > I'm looking for an efficient means of resetting a userform's controls to
> > default values for use in a userform's Activate event.  In the case at
> hand,
> > the control types are known so I could specify the types in the code.

> > This doesn't work, but it should be clear from it what it is I want to
do.
> > What changes would you suggest to get it working?

> >     Dim ctl As MSForms.Control

> >     For Each ctl In Controls
> >         If ctl.Type = TextBox Then
> >             ctl.Value = ""
> >         ElseIf ctl.Type = CheckBox Then
> >             ctl.Value = False
> >         End If
> >         . . .
> >     Next ctl

> > Thanks,

> > Alder



Sun, 14 Aug 2005 04:54:21 GMT  
 Resetting userform controls en mass
Thanks, Perry.  Just what I needed.

Cheers,
Alder


Quote:
> This is one of the ways to do it

>      For Each ctl In Controls
>          If TypeName(ctl) = "TextBox" Then
>              ctl.Value = ""
>          ElseIf TypeName(ctl) = CheckBox Then
>              ctl.Value = False
>          End If
>      Next ctl

> Krgrds,
> Perry



> > I'm looking for an efficient means of resetting a userform's controls to
> > default values for use in a userform's Activate event.  In the case at
> hand,
> > the control types are known so I could specify the types in the code.

> > This doesn't work, but it should be clear from it what it is I want to
do.
> > What changes would you suggest to get it working?

> >     Dim ctl As MSForms.Control

> >     For Each ctl In Controls
> >         If ctl.Type = TextBox Then
> >             ctl.Value = ""
> >         ElseIf ctl.Type = CheckBox Then
> >             ctl.Value = False
> >         End If
> >         . . .
> >     Next ctl

> > Thanks,

> > Alder



Sun, 14 Aug 2005 05:55:43 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Mass-validate userform controls

2. Variable(s) Reset by Showing 2nd UserForm on top 1st UserForm

3. Export Email en mass from OE6?

4. get rid of old appts en mass

5. Resetting variables in userform

6. Resetting objects in userform

7. Reset a UserForm

8. recalling a userform and resetting document

9. Userform Controls vs. Worsheet Controls

10. convert 123,50 to honderd en drientwintig en 50/100


 
Powered by phpBB® Forum Software © phpBB Group