You need to create a collection object named Headers, right? Or is that a module-level variable that has already been set?
>I'v added a control dynamically, and now I want to place
>the control in a collection. I'm getting the error
>"Object variable or With block variable not set" on the bold line:
>
>
>Private WithEvents ctlExtender As VBControlExtender
>Private Headers As Collection
>
>
>Public Function AddGroup(Caption As String) As Object
>
> Dim sName As String
> Dim iGroup As Integer
>
> iTotHeaders = iTotHeaders + 1
> sName = "Header" + LTrim(Str(iTotHeaders))
>
> Set ctlExtender = Controls.Add("SuperSideBar.crlButton", sName)
>
> With ctlExtender
>
> .Alignment = 1
> .Caption = Caption
> .Left = 10
> .Top = 10
> .Width = UserControl.Width - 23
>
> .Visible = True
>
> End With
>
>
> Headers.Add ctlExtender, sName
>>
> Set AddGroup = ctlExtender
>
>End Function
The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts. - Bertrand Russell