I'm stumped on a subform control reference issue.
I am creating a budgeting database that will budget projects that may not align with calendar years (ie the first month of a project year could be any month). The user chooses the expected start month when the budget is created, but that can change.
I have a form that allows the user to select the project and a version of the budget. On the form is tabcontrol with up to 10 tabs, representing each budget year; on each tab is a subform, whose source object is one of 10 subforms. Depending on the length of the project, I hide the tabs that are irrelevant.
I would like to change the name of the captions for each of the month fields on the subform to correspond with the apppropriate calendar period. So that if a project year, month1 is Sept 2007, the caption reads 200709. I have a function that creates the text.
My problem is that the subform reference isn't working... I get an error saying that Access can't find the form.
Here is my module:
Dim strFormName As String, strQueryName As String
DoCmd.Echo False, "Getting Budget Information ..."
Dim strType As String
Dim strSubformName As String
Dim strMonthLabel As String
Dim OffsetMonths As Integer
Dim strCaption As String
Select Case .cmdLevel.Caption
Case "GL Acct Level"
strType = "GrantCat"
Case "AcctCat Level"
strType = "GLAcct"
Case "GrantCat Level"
strType = "AcctCat"
If Not IsNull(.cboProject) And Not IsNull(.cboVersion) And Not IsNull(.cboStartYear) And Not IsNull(cboStartMonth) And Not IsNull(strType) Then
For x = 0 To 9
If x >= .txtTotalYears Then
.tabctlYears.Pages(x).Visible = False
strFormName = "sfrmPage" & x + 1
' .Form(strFormName).SourceObject = "sfrmBlank"
.tabctlYears.Pages(x).Visible = True
For z = 1 To 12
strMonthLabel = "Month" & z & "_Label"
OffsetMonths = x * 12
strCaption = CalcFiscPer(CDbl(.cboStartYear), CDbl(.cboStartMonth), x + OffsetMonths)
Problem Here ---> !Form(strFormName).Controls(strMonthLabel).Caption = strCaption
.Form(strFormName).SourceObject = strSubformName
MsgBox "Please make full selections"
.Visible = True
.cmdExtData.Visible = True
.cmdShow.Visible = True
.Visible = True