Hello All,
What I am trying to do is validate the year on opening a report.
The report contains a textbox that has function to determine the current year.
I have a form with all my reports and the user can select to view an old table or the current years. I do not want to create a report for each instance, since I have coded my form to change the report record source based on user selections.
The problem is if the user selects, say 2002, the data is from the 2002 table but the textbox is referring to the current year.
I want to validate the current year. Say the user is viewing 2002 table in 2003, textbox refers to 2003. I want to be able to change the textbox with a user selection to the correct year.
I have been playing with some code, but when I try to update the text box I get an error "Can't assign value to this object'.
Here is the code:
Private Sub Report_Open(Cancel As Integer)
If MsgBox("Is Current Year " & FiscalYear(Now()) & "?", vbYesNo) = vbYes Then
Exit Sub
Else
Me.txtFiscalYear = InputBox("What Year Then?")
End If
End Sub
I am I offbase here? How do you change an object on a report dynamically?
Thanks
Dan
What I am trying to do is validate the year on opening a report.
The report contains a textbox that has function to determine the current year.
I have a form with all my reports and the user can select to view an old table or the current years. I do not want to create a report for each instance, since I have coded my form to change the report record source based on user selections.
The problem is if the user selects, say 2002, the data is from the 2002 table but the textbox is referring to the current year.
I want to validate the current year. Say the user is viewing 2002 table in 2003, textbox refers to 2003. I want to be able to change the textbox with a user selection to the correct year.
I have been playing with some code, but when I try to update the text box I get an error "Can't assign value to this object'.
Here is the code:
Private Sub Report_Open(Cancel As Integer)
If MsgBox("Is Current Year " & FiscalYear(Now()) & "?", vbYesNo) = vbYes Then
Exit Sub
Else
Me.txtFiscalYear = InputBox("What Year Then?")
End If
End Sub
I am I offbase here? How do you change an object on a report dynamically?
Thanks
Dan