Jim
Thu Sep 21 14:08:19 CDT 2006
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote:
> As far as I can tell, it'll work for what he's trying to do. It uses
> polymorphism (I knew I'd eventually use that word in a sentence ;-)
> on controls that have been added using Controls.Add.
It's been awhile since I've messed with VBA as well.
Creating controls dynamically in VBA presents some problems.
There's no Index property on the controls and Microsoft prevented
the standard VB mechanisms from working. I tried:
Dim MyNewTextBoxes() As TextBox
ReDim MyNewTextBoxes(10)
For i = 1 to 10
Set MyNewTextBoxes(i) = New TextBox
Next i
The VBA IDE compiled it fine. However, starting the form up in
Access presents a "Run-time error '429'", "ActiveX component
can't create object".
I ended up googling through the newsgroups to look for help
and came up with the following:
http://j-walk.com/ss/excel/tips/tip76.htm
Some of the MSForms.<controltype> items there convert
to Access.<controltype> pretty easily, take for instance,
a Form...
Dim NewOptionButton As Msforms.OptionButton
converts to:
Dim NewOptionButton As Access.OptionButton
But I ran into some other problems involving VBComponents.
Those seem to be a part of the Visual Basic for Applications
Extensibility... whew that's a long one.
The link above mentions that the VBA Extensibility Library does
NOT need to be referenced but... and that perhaps only applies
to Excel. :-/
Some folks in the Excel newsgroup advise taking a gander at
the following page,
http://www.cpearson.com/excel/vbe.htm. If
the OP is using Excel, the VBA questions should be directed to
the following group:
microsoft.public.excel.programming
I've gotten some help there in the past with a variety of
things when messing with forms and such inside of Excel.
I messed with the VB environment for Access and I feel so
trapped in that environment. :-)
I like the Excel VBA environment a little better than the
Access VBA environment, but that's not saying much. It
serves a purpose occasionally whereas the Access macros
served a purpose when I was first working through some
things.
--
Jim Carlock
Post replies to the group.