jeran042
Registered User.
- Local time
- Today, 02:21
- Joined
- Jun 26, 2017
- Messages
- 127
Good afternoon all,
Here is what I am trying to accomplish
I have a group of controls (unbound calculated text boxes and labels) on a report that I only want to be visible if there are values in the calculation.
For example: When I open the Accounting report, I only want to make fields visible in this group if there is a dollar amount in the control.
Here is what I have for code:
I am getting the Run-time error 2424 Cannot find object.
Please note that I have also tried this in the On Open event, but with no success. I believe the problem is it takes a second for all the calculations to happen, so I think its isn't finding a filed because no data is loaded yet. Please correct me if I am incorrect?
My questions is, would I be better served by going about this in a different way or using a different event?
Here is what I am trying to accomplish
I have a group of controls (unbound calculated text boxes and labels) on a report that I only want to be visible if there are values in the calculation.
For example: When I open the Accounting report, I only want to make fields visible in this group if there is a dollar amount in the control.
Here is what I have for code:
Code:
Private Sub Report_Load()
Dim ctrl As Control
Dim lTotal As Long
lTotal = [Reports]![RPT: ON_SCREEN_REPORT_2019]![txtMajor_2017] 'this is the line that throws the error
For Each ctrl In Me.Controls
If ctrl.Tag = "Major" And lTotal > 2000000 Then
ctrl.Visible = FALSE
End If
Next
Debug.Print Me.txt_2017_Total_Employees
End Sub
I am getting the Run-time error 2424 Cannot find object.
Please note that I have also tried this in the On Open event, but with no success. I believe the problem is it takes a second for all the calculations to happen, so I think its isn't finding a filed because no data is loaded yet. Please correct me if I am incorrect?
My questions is, would I be better served by going about this in a different way or using a different event?