Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    not a valid bookmark (a2k)

    I'm trying to find and fix a "not a valid bookmark" error. I don't get the error, but another user does. It always seems to happen when they use the second of two different ways to open a quick data entry form. The first method for opening the form is the NIL event of a find record combo box on the main form. The second is a command button for opening the form.

    The OnClose event for the quick data entry form contains the following code:

    Dim frm As Form
    Dim strFormName As String
    Dim lngConsumerID As Long

    strFormName = "frmConsumer" 'set variable to name of main form

    IsLoaded(strFormName) Then
    Set frm = Forms(strFormName) 'make frm refer to main form
    'set this variable to this Add form control

    lngConsumerID = Me![txtConsumerID]

    DoCmd.Close
    frm.Requery 'requery original form
    frm![cboFindConsumer].Requery 'requery the main form combo box
    frm.[cboFindConsumer] = lngConsumerID 'set the combo box value
    frm.RecordsetClone.FindFirst "[lngConsumerID] = " & frm![cboFindConsumer]
    frm.Bookmark = frm.RecordsetClone.Bookmark
    Else
    DoCmd.Close acForm, Me.Name, acSaveNo
    End If

    The only other bookmark is in the AfterUpdate event of the find record combo box on the main form:

    Dim objRs As Object

    Set objRs = Me.Recordset.Clone
    objRs.FindFirst "[lngConsumerID] = " & Str(Nz(Me![cboFindConsumer], 0))
    If Not objRs.EOF Then
    Me.Bookmark = objRs.Bookmark
    End If

    Can you see a source for the bookmark error?

    E

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: not a valid bookmark (a2k)

    I notice that the On Close code does not test if the FindFirst succeeded, the way the After Update code does.

    But the best way to find out where the error occurs is to go to the user's PC and see if you (or the user) can reproduce the error, then enter debug mode to see which line of code is highlighted.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: not a valid bookmark (a2k)

    Hans,

    Will debug on site. In the meantime would you be willing to help this newbie out on the code for testing for sucess on the FindFirst in the OnClose event? I'm assuming an If...Then...Else. Do I need to dim an object as the wizard written code did?

    E

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: not a valid bookmark (a2k)

    You can try replacing

    frm.RecordsetClone.FindFirst "[lngConsumerID] = " & frm![cboFindConsumer]
    frm.Bookmark = frm.RecordsetClone.Bookmark

    by the following, modeled after the wizard-generated code:

    Dim objRs As Object
    Set objRs = frm.RecordsetClone
    objRs.FindFirst "[lngConsumerID] = " & frm![cboFindConsumer]
    If Not objRs.EOF Then
    frm.Bookmark = objRs.Bookmark
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •