L
Larry Salvucci
I have a form with 12 subforms on it that I use to filter my data by a
specific year. I have 1 subform for each month. The users will then be able
to choose a specific year from my combo box in the main forms header. Then
the subforms are filtered to that year. This is the code I'm using in the
after update event of my combo box. Is there a way to simplify this code
instead of making it so repetitive?
Dim MyRecSet As Object
Dim MyRecSet1 As Object
Dim MyRecSet2 As Object
Dim MyRecSet3 As Object
Dim MyRecSet4 As Object
Dim MyRecSet5 As Object
Dim MyRecSet6 As Object
Dim MyRecSet7 As Object
Dim MyRecSet8 As Object
Dim MyRecSet9 As Object
Dim MyRecSet10 As Object
Dim MyRecSet11 As Object
Set MyRecSet = Me.frmPerformance01.Form.RecordsetClone
Set MyRecSet1 = Me.frmPerformance02.Form.RecordsetClone
Set MyRecSet2 = Me.frmPerformance03.Form.RecordsetClone
Set MyRecSet3 = Me.frmPerformance04.Form.RecordsetClone
Set MyRecSet4 = Me.frmPerformance05.Form.RecordsetClone
Set MyRecSet5 = Me.frmPerformance06.Form.RecordsetClone
Set MyRecSet6 = Me.frmPerformance07.Form.RecordsetClone
Set MyRecSet7 = Me.frmPerformance08.Form.RecordsetClone
Set MyRecSet8 = Me.frmPerformance09.Form.RecordsetClone
Set MyRecSet9 = Me.frmPerformance10.Form.RecordsetClone
Set MyRecSet10 = Me.frmPerformance11.Form.RecordsetClone
Set MyRecSet11 = Me.frmPerformance12.Form.RecordsetClone
MyRecSet.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet1.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet2.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet3.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet4.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet5.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet6.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet7.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet8.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet9.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet10.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet11.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
specific year. I have 1 subform for each month. The users will then be able
to choose a specific year from my combo box in the main forms header. Then
the subforms are filtered to that year. This is the code I'm using in the
after update event of my combo box. Is there a way to simplify this code
instead of making it so repetitive?
Dim MyRecSet As Object
Dim MyRecSet1 As Object
Dim MyRecSet2 As Object
Dim MyRecSet3 As Object
Dim MyRecSet4 As Object
Dim MyRecSet5 As Object
Dim MyRecSet6 As Object
Dim MyRecSet7 As Object
Dim MyRecSet8 As Object
Dim MyRecSet9 As Object
Dim MyRecSet10 As Object
Dim MyRecSet11 As Object
Set MyRecSet = Me.frmPerformance01.Form.RecordsetClone
Set MyRecSet1 = Me.frmPerformance02.Form.RecordsetClone
Set MyRecSet2 = Me.frmPerformance03.Form.RecordsetClone
Set MyRecSet3 = Me.frmPerformance04.Form.RecordsetClone
Set MyRecSet4 = Me.frmPerformance05.Form.RecordsetClone
Set MyRecSet5 = Me.frmPerformance06.Form.RecordsetClone
Set MyRecSet6 = Me.frmPerformance07.Form.RecordsetClone
Set MyRecSet7 = Me.frmPerformance08.Form.RecordsetClone
Set MyRecSet8 = Me.frmPerformance09.Form.RecordsetClone
Set MyRecSet9 = Me.frmPerformance10.Form.RecordsetClone
Set MyRecSet10 = Me.frmPerformance11.Form.RecordsetClone
Set MyRecSet11 = Me.frmPerformance12.Form.RecordsetClone
MyRecSet.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet1.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet2.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet3.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet4.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet5.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet6.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet7.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet8.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet9.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet10.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search
MyRecSet11.FindFirst "[YearCount]=" & Chr(34) & Me.cboYear & Chr(34) 'string
search