Results 1 to 10 of 10
  1. #1
    Lounger
    Join Date
    May 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access VB 'Bookmark' (2000)

    I have a form that contains a combo box that is used for finding records. This form also contains a command button which duplicates the record. When I click the duplicate button, it gives me a run-time error '3058' Index or primary key cannot contain a Null value. When I click debug on this message it takes me to the VB code for the combo box and highlights Me.Bookmark = rs.Bookmark.

    It duplicates, but gives me this message everytime. If I remove the primary key combination from the underlying table this problem disappears. However, I do need the primary keys for other forms to operate as desired.

    The complete code for the combo box is :

    Private Sub Combo230_AfterUpdate()
    'Find the record that matches the control
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Search Field]="""&Me![Combo230]&""""
    If Not rs.EOF Then Me.Bookmark=rs.Bookmark
    End Sub

    I greatly appreciate any guidance.

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

    Re: Access VB 'Bookmark' (2000)

    Do you have other code that sets the text of the combo box? Is the search combo box bound to a field? (it shouldn't be)

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Access VB 'Bookmark' (2000)

    Technically, you should not be checking the .EOF property, rather you should be check the .NoMatch property. I don't know if this may be part of your problem or not. What is your code that actually duplicates the record?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Lounger
    Join Date
    May 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access VB 'Bookmark' (2000)

    The code that duplicates the record is the following: (Thank you for your help)

    Private Sub Command216_Click()
    On Error GoTo Err_Command216_Click

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
    DoCmd.Requery ([qry_Policy Form for UW])

    Exit_Command216_Click:
    Exit Sub

    Err_Command216_Click:
    MsgBox "PLEASE MAKE SURE THAT YOU UPDATE THE EFFECTIVE DATE IMMEDIATELY"
    [Effective Date].SetFocus
    Resume Exit_Command216_Click

    End Sub

  5. #5
    Lounger
    Join Date
    May 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access VB 'Bookmark' (2000)

    The combo box is an unbound field.

    Thanks,

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Access VB 'Bookmark' (2000)

    In an ADO recordset, you check for EOF and BOF to see whether there was a match on a Find. In a DAO recordset, you use the NoMatch property to test. You're working with a DAO recordset, so you need the NoMatch property.
    Charlotte

  7. #7
    Lounger
    Join Date
    May 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access VB 'Bookmark' (2000)

    Charlotte,
    Thank you. Do you have an example of such a code? I have not used the NoMatch property before.

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Access VB 'Bookmark' (2000)

    Private Sub Text1_AfterUpdate()
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[CustomerID] = '" & Me.Text1 & "'"
    If Not rs.NoMatch Then
    Me.Bookmark = rs.Bookmark
    End If
    End Sub
    Charlotte

  9. #9
    Lounger
    Join Date
    May 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access VB 'Bookmark' (2000)

    I tried the NoMatch property, still gives me the run-time error and highlights Me.Bookmark=rs.Bookmark

    I guess the issue lies in the fact that the combo box that is used for finding is based on a query that concatenates three fields. Is there a way around this?

    I appreciate all responses so far very much.

    Thank you

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Access VB 'Bookmark' (2000)

    I don't understand. Doesn't your combobox have a hidden column that contains a unique key of some kind? You'll never get a match to the text in the combobox if there is no match in a comparable field in your form's recordset. Did you make the NoMatch part of a conditional test? You can't set the current bookmark in the form to null, which is what it sounds like you're trying to do, and that will happen if no match was found and you still try to set the bookmark.
    Charlotte

Posting Permissions

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