Run-time error '2465'

riggsd

Board Regular
Joined
Jan 29, 2003
Messages
143
I really don't like debugging even though I know it's necessary.

I'm getting a run-time error 2465, application-defined or object-defined error, that I don't know how to fix, despite multiple searches in various Access forums. The line highlighted below is where I'm getting the error. I'm sure there are ways to optimize my code but I'm just trying to get this done at the moment.

Code:
Public Function SetDueDate()

    Dim deliveryDue As Date 'calculated delivery date
    Dim startDate As Date 'DO/TO start date
    Dim Msg, Style, Title, Response
    
    DoCmd.OpenForm "frmDeliveriesReceived"

    'check if event date is blank
    If IsNull(Forms!frmDeliveriesReceived.Form.Event1_Date) Then 'if event date is blank
        'check if event is DAC
        If Forms!frmDeliveriesReceived.Form.Event1_Due_For.Column(1) = "After Contract Award" Then 'if it is DAC
            'get start date
            [highlight]startDate = DLookup("Start_Date", "tblDeliveryTaskOrders", "Task_ID = " & Forms!frmDeliveriesReceived.frmDeliveriesReceived_Subform.Form.Delivery_Task_Order)[/highlight]
            SetDueDate = FindDueDate(Forms!frmDeliveriesReceived.Form.Event1_Due_For.Column(1), startDate) 'call function to determine calculated due date
        Else 'if event date is blank and not DAC, display error message
            'set up msgbox
            Msg = "Event Date cannot be blank."
            Style = vbOKOnly
            Title = "Check Blank Event Date"
            'display msgbox
            Response = MsgBox(Msg, Style, Title)
            SetDueDate = "" 'set due date to blank
            'Exit Function 'return to calling sub
        End If
    Else 'if event date is not blank
        'check if manual date selected
        If Forms!frmDeliveriesReceived.Form.Manual_Date_Due = True Then 'if it is selected
            'verify that it is correct
            SetDueDate = FindDueDate(Forms!frmDeliveriesReceived.Form.Event1_Due_For.Column(2), Forms!frmDeliveriesReceived.Form.Event1_Date) 'call function to determine calculated due date
            'check that current date equals calculated date
            If Forms!frmDeliveriesReceived.Form.Event1_Date = SetDueDate Then 'if it matches
                SetDueDate = "" 'set due date to blank so calling sub will ignore it
                Exit Function 'return to calling sub
            Else 'if date does not match, show error message
                'set up msgbox
                Msg = "Initial Due Date is set to " & Forms!frmDeliveriesReceived.Form.Event1_Date & vbCrLf & _
                "should be " & deliveryDue & "." & vbCrLf & vbCrLf & _
                "To keep the current date, press 'Yes.'" & vbCrLf & _
                "To change the date, press 'No.'"
                Style = vbYesNo
                Title = "Verify Manual Date Set"
                'display msgbox
                Response = MsgBox(Msg, Style, Title)
                If Response = vbNo Then 'if user selects No
                    'do nothing and keep SetDueDate at current calculated value
                    Exit Function ' return to calling sub
                Else 'if user selects Yes
                    SetDueDate = "" 'set due date to blank so calling sub will ignore it
                    Exit Function 'return to calling sub
                End If
            End If
        Else 'if manual date is not selected
            'do nothing and keep SetDueDate at current calculated value
            Exit Function 'return to calling sub
        End If
    End If

End Function
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
2465 means an object did not get created...a form , a subform, etc.

The hilite sez its probably the sub form.
Dont use periods in places, and dont type out form objects by hand. DO USE the BUILDER. (magic wand icon) It will spell everything correctly, just by clicking what you want.
Verify this 1st then try something else.

Its also possible the DLookup did not return a value, ...you'll get an error there too.
You can spot check values by typing in the immediate window (ctl-G)
? forms!frmMyForm!txtBox

to see if youre gettting what you think youre getting
 
Last edited:
Upvote 0
Thanks, I was just returning to reply that I'd figured it out - basically what you said.

Somehow, the subform name got changed to the form caption so it was trying to find [Verify Relation] instead of frmDeliveriesReceived_Subform. I changed the name and the error no longer displays.
 
Upvote 0

Forum statistics

Threads
1,224,271
Messages
6,177,620
Members
452,786
Latest member
k3calloway

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top