using ctl.tag to set to default value

  • Thread starter Thread starter Lesli
  • Start date Start date
L

Lesli

I'm using the following code to make checkboxes visibile or not.

If ctl.Tag = "Cert" Then
ctl.Visible = False
End If

Is there also a way, using the ctl.Tag = "Cert", to set the value of each of
those same controls to their default value?

I'm not married to using the .tag option. I'd just rather not have to code
each of them individually because there are a lot of them.

Thanks,
Lesli
 
Untested, but try:

If ctl.Tag = "Cert" Then
ctl = ctl.DefaultValue
ctl.Visible = False
End If
 
Try

ctl.Value = ctl.DefaultValue

and if that still doesn't work, try

ctl.Value = CBool(ctl.DefaultValue)
 
I LOVE this site. I learn something new from y'all every time I'm out here.

I had a mixture of checkboxes, textboxes and labels all with the same tag.
I took the tag off the labels and was still getting a message when I tried to
set the remaining tagged controls to their default value.

So then I tagged each control type separately with "Certchk" for the
checkboxes or "Certdt" for the textboxes. Instead of setting each to a
default value I'm just setting the checkboxes to "0" and the textboxes to ""
(which is what the default values are anyway). There's probably still a
better, more efficient way but at least this is working.

Thanks for your help!

Lesli
 
I get a run time error 438 Object odesn't support this property or
method.

On which control? If you're looping through the entire controls
collection, then you'd encounter things like labels and lines that
don't have those properties. It seems likely that you're getting the
error because the control it's on does not have that property.
Perhaps you've mistakenly tagged a control that's not supposed to be
tagged?
 
Back
Top