Run-Time error 2465 (1 Viewer)

5hadow

Member
Local time
Today, 01:52
Joined
Apr 26, 2021
Messages
89
Hello

I'm having issues with following code:

Code:
            strBody = "An AMMIS Correction is required for Form Serial Number " & Me.parent.fldAmmisd349 & " due to the following reason(s): " & vbNewLine & vbNewLine & _
                "- " & Me.parent.fldObservation & vbNewLine & vbNewLine & vbNewLine & _
                "______________________________________________________________________________________________________" & vbNewLine & _
                "NOTE - REFDES YGA shall ONLY be used to report form corrections to errors in the Airworthiness data fields (text fields) and as such shall not change the aircraft status." & vbNewLine & _
                "NOTE - Missing and/or forgotten maintenance tasks are NOT a correction and require maintenance certification using a normal CF 349 or CF 543. (i.e support work, functionals or torques). " & vbNewLine & _
                "a)Please open a new CF349 with YGA as RefDes, AMMIS as the Supp Data." & vbNewLine & _
                "b)In the Unserviceability field enter the name of the field to be corrected and the reason for the correction." & vbNewLine & _
                "c)In the Rectification field enter the field name(s) and the correct information for that field." & vbNewLine & _
                "d)In Section 7 on sequence line 1, enter WUC YGA in the Items data field. All other fields shall remain blank." & vbNewLine & _
                "e)On the next sequence line, enter RPT code L and in the Items data field enter the Control Number of the CF 349 being corrected (" & Me.parent.fldAdminsd349 & ")." & vbNewLine & _
                "NOTE - Please ensure to look at the Squadron MAP AMCRO Examples prior to calling AMCRO for guidance." & vbNewLine & _
                "Thank you for your assistance." & vbNewLine & _
                "______________________________________________________________________________________________________"

I get Run-time error '2465':
Application-defined or object-defined error

Any ideas on how to fix?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:52
Joined
Oct 29, 2018
Messages
21,454
Hi. Welcome to AWF!

Is that the whole code, or is that what is getting highlighted when you get the error message?
 

5hadow

Member
Local time
Today, 01:52
Joined
Apr 26, 2021
Messages
89
Only this part is getting highlighted
Hi. Welcome to AWF!

Is that the whole code, or is that what is getting highlighted when you get the error message?
Here's the rest:

Code:
Private Sub btnSend_Click()

    ' Get the COC
    Dim strEmail As String
    Dim strCCEmail As String
    Dim strSubject As String
    Dim strBody As String
    
    ' Make sure there is an email
    If IsNull(Me.parent.fldMemberID) Or IsEmpty(Me.parent.fldMemberID) Then
        Err.Number = "94"
        GoTo ErrHandle
    End If
    
    ' Get email
    strEmail = Nz(DLookup("fldEmail", "tblMember", "ID = " & Me.parent.fldMemberID), "")
    
    ' Check for email
    If IsNull(strEmail) Or IsEmpty(strEmail) Or Not Len(strEmail) > 0 Then
        Err.Number = "94"
        GoTo ErrHandle
    End If

    ' The COC Email
    strCCEmail = IIf(IsNull(Me.parent.fldSameoDate), "", DLookup("fldEmail", "tblCCEmail", "fldCC = 'SAMEO'") & ";") & _
        IIf(IsNull(Me.parent.fldSameoDate), "", DLookup("fldEmail", "tblCCEmail", "fldCC = 'FS'") & ";") & _
        DLookup("fldEmail", "tblCCEmail", "fldCC = 'ASO'") & ";" & _
        DLookup("fldEmail", "tblCCEmail", "fldCC = 'ASO1'") & ";" & _
        DLookup("fldEmail", "tblCCEmail", "fldCC = 'ASO2'") & ";" & _
        DLookup("fldEmail", "tblCCEmail", "fldCC = 'ARO'") & ";" & _
        DLookup("fldEmail", "tblCCEmail", "fldCC = 'AMCRO'")

    ' Get sent
    With CurrentDb.OpenRecordset("SELECT * FROM tblAmmisObservationSent WHERE " & "fldObservationID = " & Me.parent.ID)
    
        If .EOF = True Then
        
            ' Subject
            strSubject = "AMMIS Observation for " & Me.parent.fldAmmisd349 & " - DO NOT DELETE!"
    

            strBody = "An AMMIS Correction is required for Form Serial Number " & Me.parent.fldAmmisd349 & " due to the following reason(s): " & vbNewLine & vbNewLine & _
                "- " & Me.parent.fldObservation & vbNewLine & vbNewLine & vbNewLine & _
                "______________________________________________________________________________________________________" & vbNewLine & _
                "NOTE - REFDES YGA shall ONLY be used to report form corrections to errors in the Airworthiness data fields (text fields) and as such shall not change the aircraft status." & vbNewLine & _
                "NOTE - Missing and/or forgotten maintenance tasks are NOT a correction and require maintenance certification using a normal CF 349 or CF 543. (i.e support work, functionals or torques). " & vbNewLine & _
                "a)Please open a new CF349 with YGA as RefDes, AMMIS as the Supp Data." & vbNewLine & _
                "b)In the Unserviceability field enter the name of the field to be corrected and the reason for the correction." & vbNewLine & _
                "c)In the Rectification field enter the field name(s) and the correct information for that field." & vbNewLine & _
                "d)In Section 7 on sequence line 1, enter WUC YGA in the Items data field. All other fields shall remain blank." & vbNewLine & _
                "e)On the next sequence line, enter RPT code L and in the Items data field enter the Control Number of the CF 349 being corrected (" & Me.parent.fldAdminsd349 & ")." & vbNewLine & _
                "NOTE - Please ensure to look at the Squadron MAP AMCRO Examples prior to calling AMCRO for guidance." & vbNewLine & _
                "Thank you for your assistance." & vbNewLine & _
                "______________________________________________________________________________________________________"

                
        Else
            .MoveLast
            
            ' Subject
            strSubject = "Reminder - You have an Open AMMIS Observation for " & Me.parent.fldAmmisd349 & " - DO NOT DELETE!"
                
            strBody = "An AMMIS Correction is required for Form Serial Number " & Me.parent.fldAmmisd349 & " due to the following reason(s): " & vbNewLine & vbNewLine & _
                "- " & Me.parent.fldObservation & vbNewLine & _
                "______________________________________________________________________________________________________" & vbNewLine & _
                "NOTE - REFDES YGA shall ONLY be used to report form corrections to errors in the Airworthiness data fields (text fields) and as such shall not change the aircraft status." & vbNewLine & _
                "NOTE - Missing and/or forgotten maintenance tasks are NOT a correction and require maintenance certification using a normal CF 349 or CF 543. (i.e support work, functionals or torques). " & vbNewLine & _
                "a)Please open a new CF349 with YGA as RefDes, AMMIS as the Supp Data." & vbNewLine & _
                "b)In the Unserviceability field enter the name of the field to be corrected and the reason for the correction." & vbNewLine & _
                "c)In the Rectification field enter the field name(s) and the correct information for that field." & vbNewLine & _
                "d)In Section 7 on sequence line 1, enter WUC YGA in the Items data field. All other fields shall remain blank." & vbNewLine & _
                "e)On the next sequence line, enter RPT code L and in the Items data field enter the Control Number of the CF 349 being corrected (" & Me.parent.fldAdminsd349 & ")." & vbNewLine & _
                "NOTE - Please ensure to look at the Squadron MAP AMCRO Examples prior to calling AMCRO for guidance." & vbNewLine & _
                "This has been opened since " & Me.parent.fldOpenedDate & ", and has been sent " & .RecordCount + 1 & " time(s)!" & vbNewLine & _
                "Thank you for your assistance." & vbNewLine & _
                "______________________________________________________________________________________________________"

            
            

        End If
        
        ' Attached file name
        tempFN = Me.parent.fldAmmisd349 & ".pdf"
        
        On Error GoTo ErrHandle
        DoCmd.OpenReport "AmmisForm", acViewPreview, , "tblAmmisObservations.ID = " & Me.parent.ID, acHidden
        DoCmd.SendObject acSendReport, "AmmisForm", acFormatPDF, strEmail, strCCEmail, , strSubject, strBody, True
        
        .AddNew
            ![fldObservationID] = Me.parent.ID
            ![fldSentDate] = FormatDateTime(Now(), 2)
        .Update
        
    End With
    
    ' Update the follow up
    Me.parent.fldFollowUpDate = Format(DateAdd("d", 60, Date), "dd-mm-yyyy")
    
    GoTo EOF
    
ErrHandle:
    Select Case Err.Number
    
        Case "94"
            MsgBox "Problem With Email Address!", vbCritical, Err.Number
            
        Case "2501"
            MsgBox "Email Cancelled!", vbCritical, Err.Number
            
        Case Else
            MsgBox Err.Description, vbCritical, Err.Number
            
    End Select
    
EOF:
    DoCmd.Close acReport, "AmmisForm"

End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:52
Joined
Oct 29, 2018
Messages
21,454
Only this part is getting highlighted
Sometimes, the error message may refer to a different part of the code than the one that triggers it. You could try to reduce the amount of code continuation you're using, just for troubleshooting, in case you're running into a limit.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:52
Joined
Feb 28, 2001
Messages
27,140
My first guess is that you should check your fields where you are doing substitution to verify that none of them contain quoting characters. You might be able to set a breakpoint in the code and use Debug.Print (with the Immediate Window open) to see the value of your string. If it is truncated somewhere, that might identify the point at which you are having issues.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:52
Joined
May 7, 2009
Messages
19,231
have you posted same problem?

the issue is here:

Code:
    ' Check for email
    If IsNull(strEmail) Or IsEmpty(strEmail) Or Not Len(strEmail) > 0 Then
        Err.Number = "94"
        GoTo ErrHandle
    End If

you don't Assign Err.Number, you Raise it:

Code:
    ' Check for email
    If Len(strEmail) = 0 Then
        Err.Raise 94
    End If
 

Users who are viewing this thread

Top Bottom