Adding controls to a VBA Collection
- From: Nunzio <gg@xxxxxxxxxxx>
- Date: Thu, 29 Nov 2007 14:49:22 -0800 (PST)
I am trying to add specific form controls to a VBA collection, so that
I can pass the entire collection to another function, and access the
individual controls later. I have tried several different syntax
variations. In each case, the receiving function produces the error
'Object Required' when I try to access any property of a control in
the collection. If I reference a collection item in the debugger
using its ordinal position, I see the value of the control. So, on
the surface at least, it appears that I am only adding the control's
'value' to the collection, not the control itself; or maybe my syntax
for retrieving the control's properties is at fault. Any help would
be greatly appreciated.
Dim colControls As Collection
Dim ctl As Control
Set colControls = New Collection
'I've tried this
Set ctl = Me.txtDosage
colControls.Add (ctl)
'And this
colControls.Add Me.controls("txtLabel")
'And this
colControls.Add Me.txtLabel
'The code to receive the collection look like this
Public Function fcnLogAudit(lngRecordType As enuRecordType,
lngRecordKey As Long, _
colControls As Collection) As Boolean
Dim ctl As Control
'Error occurs on this line. If I look at ctl(1) I can see the
control's
'value, but I can't access any of it's properties
For Each ctl In colControls
If ctl.Text <> ctl.OldValue Then...
.
- Follow-Ups:
- Re: Adding controls to a VBA Collection
- From: Neil
- Re: Adding controls to a VBA Collection
- Prev by Date: Re: SQL parameter query not returning values
- Next by Date: Re: create rtf document with VBA
- Previous by thread: Re: Getting System Time From SQL Server
- Next by thread: Re: Adding controls to a VBA Collection
- Index(es):
Relevant Pages
|