Sreedhar,
Let me recommend a book for you:
Access 2000 Developer's Handbook
I highly recommend (as probably do most other developers) this book.
It is a few editions old, but it still works. It talks about how to
use the collection class, as well as some of the items that you need
to be aware of. Mainly, it discusses the Attribute line. That will
not work if you paste it directly into a class in MS Access, but will
work if you paste it into a text file with a .cls extension, then use
the Import functionality in the IDE.
Property Get Item(ByVal Index) As Control
Attribute Item.VB_UserMemId = 0
Set Item = Control.Item(Index)
End Property
This attribute sets the default item.
Public Function NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
'Enumeration function for the collection
Set NewEnum = mFlds.[_NewEnum]
End Function
This enables For Each functionality. Let me know if you run into any
problems.
Chris Nebinger
Hi Chris,
Thanks for introducing me to a new animal - the "Collection Class". The idea
is bang on what I wanted and I will try this.
Thanks once again.
--
Sreedhar
If you want this to be able to accept any number of controls, then
consider a custom collection class. You can add in individual control
objects, then pass the Controls collection to your subroutine.
Sample Collection Class Code (paste this into notepad, save it with
a .cls extension, import into Access):
Option Compare Database
Option Explicit
Private mCol As Collection
Private Sub Class_Initialize()
Set mCol = New Collection
End Sub
Public Sub Add(ctl As Control)
mCol.Add ctl, ctl.Name
End Sub
Property Get Count()
Count = mCol.Count
End Property
Property Get Item(ByVal Index) As Control
Attribute Item.VB_UserMemId = 0
Set Item = Control.Item(Index)
End Property
Public Sub Delete(ByVal Index)
mCol.Remove Index
End Sub
Public Function NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
'Enumeration function for the collection
Set NewEnum = mFlds.[_NewEnum]
End Function
Dim cls as YourClassName
dim col as new CollectionClassName
col.add control1
col.add control2
etc.
Public Sub ResizeAllControls(col as Collection)
dim ctl as control
for each ctl in col
resizectl ctl
end sub
Public Sub ResizeCtl(ctlToResize as Control)
Chris Nebinger- Hide quoted text -
- Show quoted text -