MikeD
9/4/2011 1:31:00 AM
<rraisley@bellsouth.net> wrote in message
news:67ee1b99-cbcb-4e91-a127-06f41f79e9bb@g31g2000yqh.googlegroups.com...
> I have a bunch of controls to enable/disable and make other changes
> to, and need to Refresh the parent controls to them when I'm done. I
> want to avoid refreshing multiple times, or refreshing if not
> necessary, so thought I could keep track of the Parent controls, then
> run a routine to refresh them. I've got something like this:
>
> 'This keeps track of all the Parents that need updating
> Global Parents(50), NumParents As Integer
>
> 'This is the routine called to enable/disable each control, and keep
> track of parents
> Sub SetEnabled(ByVal Ctrl as Control, ByVal Enab as Integer)
> If Ctrl.Enabled <> Enab Then
> Ctrl.Enabled = Enab
> NumParents = NumParents +1
> Parents(NumParents) = Ctrl.Parent ' <== This is the area
> there's a problem with.
> End If
> End Sub
>
> 'This routine is intended to Refresh only parents found above to need
> so:
> Sub RefreshParents()
> Dim x as Integer
> For x = 1 To NumParents
> Parents(x).Refresh
> Next x
> NumParents = 0
> End Sub
>
> I also intend to add code to include each parent in the list only
> once. Anyhow, it's the line above:
>
> Parents(NumParents) = Ctrl.Parent
>
> that errs out, with Run-time error 91, Object variable or With block
> variable not set. I'm probably not working with the control "names"
> correctly.
>
> Can someone point out my error, or give a suggestion?
Just a guess without having looked at your code in more depth (i.e. actually
trying it), but you probably want the control's container, NOT it's parent.
So, try the Container property. Also, you're dealing with objects, you need
to use the Set keyword (I am assuming this is VB6 as I didn't see anything
obvious that stood out as .NET code).
Also, you might want your Parents() array to be declared As Object and your
Enab parameter should probably be a Boolean.
--
Mike