|
|
Simulating a control array on a form in Access97QuestionIs it possible to create a control array on a form in A97? How do you do this? In VB if you copy and then paste a control, you are prompted with a dialog box that asks if you want to create a control array? Is there anything like this in access? AnswerTom, HTH, '+ *** CMyCombo ***
Private Const cstrModuleName As String = "CMyCombo"
Private WithEvents mcbo As Access.ComboBox
Public Sub Init(ByRef rcbo As Access.ComboBox)
Set mcbo = rcbo
rcbo.OnEnter = "[Event procedure]"
End Sub
Public Sub Terminate()
Set mcbo = Nothing
End Sub
Private Sub mcbo_Enter()
mcbo.Dropdown
End Sub
'- *** CMyCombo ***
'+ *** Code Behind Form ***
Dim mcolControlArray As New Collection
Private Sub Form_Load()
Dim ctl As Access.Control
Dim obj As CMyCombo
For Each ctl In Me.Form.Controls
'If TypeName(ctl) = "ComboBox" Then
If ctl.ControlType = Access.acComboBox Then
Set obj = New CMyCombo
obj.Init ctl
mcolControlArray.Add obj, ctl.Name
End If
Next
Set obj = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim obj As CMyCombo
For Each obj In mcolControlArray
obj.Terminate
Next
Set obj = Nothing
Set mcolControlArray = Nothing
End Sub
'- *** Code Behind Form ***
Copyright © 1999-2008 by Shamil Salakhetdinov. Original version is published here All rights reserved. |