Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Why getting runtime error 440 - Automation Error

I have the following code in a GroupHeader on print event.  But the code stalls and gives me a runtime error 440 - Automation Error.  When I debug, this line is highlighted in yellow:

Me.Text35 = Me.Text45 - [Reports]![Income Statement].[Report]![subrptIncomeStatementEXPENSE].[Report]![txtSumCurrentPeriod]

And when I hover over the Me.Text35 part of that line is indicated Null.

How can I overcome this issue?

Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
On Error GoTo Err_GroupHeader0_Print

    If [Reports]![Income Statement].[Report]![subrptIncomeStatementINCOME].[Report].HasData Then
        Me.Text35 = [Reports]![Income Statement].[Report]![subrptIncomeStatementINCOME].[Report]![txtSumCurrentPeriod] - [Reports]![Income Statement].[Report]![subrptIncomeStatementEXPENSE].[Report]![txtSumCurrentPeriod]
        Me.Text36 = [Reports]![Income Statement].[Report]![subrptIncomeStatementINCOME].[Report]![txtSumSamePeriodLastYear] - [Reports]![Income Statement].[Report]![subrptIncomeStatementEXPENSE].[Report]![txtSumSamePeriodLastYear]
        Me.Text37 = [Reports]![Income Statement].[Report]![subrptIncomeStatementINCOME].[Report]![txtSumYearToDate] - [Reports]![Income Statement].[Report]![subrptIncomeStatementEXPENSE].[Report]![txtSumYearToDate]
        Me.Text38 = [Reports]![Income Statement].[Report]![subrptIncomeStatementINCOME].[Report]![txtSumLastYearYearToDate] - [Reports]![Income Statement].[Report]![subrptIncomeStatementEXPENSE].[Report]![txtSumLastYearYearToDate]
        Exit Sub
    End If

    If [Reports]![Income Statement].[Report]![subrptIncomeStatementINCOME].[Report].HasData = False Then
        Me.txtCurrentPeriodSumFromExpense = 0
        Me.txtSamePeriodFromLastYearFromExpense = 0
        Me.txtYearToDateFromExpense = 0
        Me.txtYearToDateLastYEarFromExpense = 0

        Me.Text45 = 0
        Me.Text46 = 0
        Me.Text47 = 0
        Me.Text48 = 0

        Me.Text35 = Me.Text45 - [Reports]![Income Statement].[Report]![subrptIncomeStatementEXPENSE].[Report]![txtSumCurrentPeriod]
        Me.Text36 = Me.Text46 - [Reports]![Income Statement].[Report]![subrptIncomeStatementEXPENSE].[Report]![txtSumSamePeriodLastYear]
        Me.Text37 = Me.Text47 - [Reports]![Income Statement].[Report]![subrptIncomeStatementEXPENSE].[Report]![txtSumYearToDate]
        Me.Text38 = Me.Text48 - [Reports]![Income Statement].[Report]![subrptIncomeStatementEXPENSE].[Report]![txtSumLastYearYearToDate]
    End If

Exit_GroupHeader0_Print:
    Exit Sub

Err_GroupHeader0_Print:
    MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & "Error Source: " & Err.Source
    Resume Exit_GroupHeader0_Print
    
End Sub

Open in new window

SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SteveL13

ASKER

I’m traveling today but wanted to get point awarded. Both replies I found very worthwhile. I will post my solution when I return on Tuesday.
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

you're welcome, Steve ~ happy to help