RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
Having a problem setting up a class module around several option buttons I have a multipage userform (1st page). I'm getting an error on the "Redim Preserve" line - "Subscript out of range". Any idea what I'm doing wrong? Is this a multipage vs. userform issue?
Userform Code
Class Module Code
Userform Code
VBA Code:
Option Explicit
Private FilterPress() As New FilterPressClass
'public properties
Public Property Let SelectedFP(sSelectedFP As String)
msSelectedFP = sSelectedFP
End Property
Private Sub UserForm_Initialize()
Call PopulateControlArrays
End Sub
Private Sub PopulateControlArrays()
Dim Ctrl As Control
Dim lFPCount As Long
For Each Ctrl In Me.MultiPage1.Pages(0).Controls
If TypeName(Ctrl) = "OptionButton" Then
lFPCount = lFPCount + 1
ReDim Preserve FilterPress(1 To lFPCount) 'GETTING THE ERROR HERE!
Set FilterPress(lFPCount).FilterPressGroup = Ctrl
' link to this instance of UserGUI
Set FilterPress(lFPCount).FilterPressGroup.Parent = Me
End If
Next Ctrl
End Sub
Public Sub FPSet()
MsgBox msSelectedFP
End Sub
Class Module Code
VBA Code:
Option Explicit
Public WithEvents FilterPressGroup As MSForms.Control
Private mfrmParent As UserForm
'--public properties
Public Property Set Parent(frmParent As UserForm)
Set mfrmParent = frmParent
End Property
'--event procedures
Private Sub FilterPressGroup_Click()
FilterPressGroup.Parent.SelectedFP = FilterPressGroup.Name
FilterPressGroup.Parent.FPSet
End Sub