Run-time error '2499'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dee

    #1

    Run-time error '2499'

    I have a form 'FmMessages" and a form 'FmLeads'.
    'FmMessages', through code, opens 'FmMessages" if it is not already
    open.
    It then sets focus on 'FmLeads' and runs the following code:

    Dim rst As Object
    Dim Tid As Long
    If typetransfer = "Valid Number" Or typetransfer = "New Number" Then
    DoCmd.GoToRecor d , , acNewRec
    Me.ID = Forms![FmMessages].testCode
    Set rst = Me.Recordset.Cl one
    Tid = Me.ID

    If Not IsNull(DLookup( "ID", "Contacts", "ID = " & Tid)) Then
    MsgBox "ID Number Already Exists", vbExclamation, "Taking you
    to that record"
    Me.Undo
    rst.FindFirst "ID = " & Tid
    Me.Bookmark = rst.Bookmark
    End If
    ....more code here
    End if

    All of this runs just fine if 'FmLeads' was closed and then opened by
    code in 'FmMessages'.

    My problem comes when the 'FmLeads' form is already open. The line:
    DoCmd.GoToRecor d , , acNewRec
    now produces the following error:

    Run-time error '2499'
    "You can't use GoToRecord a"ction or method on an object in Design
    view"

    Needles to say, form 'FmLeads' is not open in design view, and it does
    have focus.

    Your help would be very much appreciated
  • Bruce

    #2
    Re: Run-time error '2499'

    On Aug 13, 3:48 pm, dee <promotions.mar ket...@comcast. netwrote:
    I have a form 'FmMessages" and a form 'FmLeads'.
    'FmMessages', through code, opens 'FmMessages" if it is not already
    open.
    It then sets focus on 'FmLeads' and runs the following code:
    >
    Dim rst As Object
    Dim Tid As Long
    If typetransfer = "Valid Number" Or typetransfer = "New Number" Then
        DoCmd.GoToRecor d , , acNewRec
        Me.ID = Forms![FmMessages].testCode
        Set rst = Me.Recordset.Cl one
        Tid = Me.ID
    >
        If Not IsNull(DLookup( "ID", "Contacts", "ID = " & Tid)) Then
            MsgBox "ID Number Already Exists", vbExclamation, "Takingyou
    to that record"
            Me.Undo
            rst.FindFirst "ID = " & Tid
            Me.Bookmark = rst.Bookmark
        End If
        ....more code here
    End if
    >
    All of this runs just fine if 'FmLeads' was closed and then opened by
    code in 'FmMessages'.
    >
    My problem comes when the 'FmLeads' form is already open. The line:
        DoCmd.GoToRecor d , , acNewRec
    now produces the following error:
    >
    Run-time error '2499'
    "You can't use GoToRecord a"ction or method on an object in Design
    view"
    >
    Needles to say, form 'FmLeads' is not open in design view, and it does
    have focus.
    >
    Your help would be very much appreciated
    Where does the code with the GoToRecord in it run? In the Load event
    of fmLeads? Also what is TypeTransfer? Is that a field on fmLeads or
    a function? Finally, what code are you using to actually open
    fmLeads?

    Bruce

    Comment

    Working...