Results 1 to 4 of 4
  1. #1
    racefan91 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Sep 2013
    Posts
    56

    Runtime error 2465


    I have a movie database in which I have the following code when entering the movie stars for a movie. If the actor doesn't exist in the table this code is supposed to open a form to add a name. When it tries to open the form I always get a Runtime error 2465. Any help fixing this would be greatly appreciated.

    Private Sub StarsID_NotInList(NewData As String, Response As Integer)
    Dim ans As Integer
    Response = acDataErrContinue
    ans = MsgBox("Do you want to add this Star?", vbYesNo, " A D D N E W S T A R ")
    Select Case ans
    Case vbNo
    Case vbYes
    DoCmd.OpenForm ("frmStars"), , , , acFormAdd
    Forms!frmStars.txtStarName = NewData
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.Close acForm, "frmStars"
    Response = acDataErrAdded
    Case Else
    End Select
    End Sub

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Adjusted/formatted code to show indenting (orange)

    Code:
    Private Sub StarsID_NotInList(NewData As String, Response As Integer)
        Dim ans As Integer
        Response = acDataErrContinue
        ans = MsgBox("Do you want to add this Star?", vbYesNo, " A D D N E W S T A R ")
        Select Case ans
            Case vbNo
            Case vbYes
                DoCmd.OpenForm ("frmStars"), , , , acFormAdd
                Forms!frmStars.txtStarName = NewData
                DoCmd.RunCommand acCmdSaveRecord
                DoCmd.Close acForm, "frmStars"
                Response = acDataErrAdded
            Case Else
        End Select
    End Sub
    ?accesserror(2465)
    Microsoft Access can't find the field '|1' referred to in your expression.@You may have misspelled the field name, or the field may have been renamed or deleted.@@1@1@11730@1

    Can you show us the actual calling code (with values) that fails?

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    You don't need the form at all. Adjust the red to adhere to your DB defs.

    Code:
    Private Sub StarsID_NotInList(NewData As String, Response As Integer)
        Dim sSQL As String
        If MsgBox("""" & NewData & """ is not defined. " & vbCr & vbCr _
            & "Do you want to add it now?", vbQuestion + vbYesNo, "Invalid Selection") = vbYes Then
                sSQL = "INSERT INTO tblStars (StarName) Values (" & "'" & NewData & "'" & ")"
                CurrentDb.Execute sSQL, dbFailOnError
                Response = acDataErrAdded
        Else
                MsgBox "Please select an item from the list.", _
                    vbExclamation + vbOKOnly, "Invalid Entry"
                Response = acDataErrContinue
        End If

  4. #4
    racefan91 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Sep 2013
    Posts
    56
    Awesome that works! Much thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Runtime Error 2465
    By Eranka in forum Access
    Replies: 1
    Last Post: 07-09-2018, 02:07 AM
  2. Replies: 9
    Last Post: 06-15-2017, 04:28 PM
  3. Replies: 2
    Last Post: 01-15-2015, 01:10 AM
  4. runtime error 2465 'l1'
    By mike02 in forum Forms
    Replies: 5
    Last Post: 07-17-2013, 03:37 PM
  5. Not figuring out dlookup (RunTime 2465)
    By Gilligan in forum Access
    Replies: 10
    Last Post: 03-08-2011, 02:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums