How to use bookmark property with recordset based on query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tuxalot
    New Member
    • Feb 2009
    • 200

    #1

    How to use bookmark property with recordset based on query?

    I am trying to move to the first record in a form where a value is false. The underlying form uses a query as it's record source. I am getting an "invalid argument" error where indicated below in code:
    Code:
        Dim intCountMissing As Integer
        Dim strCriteria As String
        'check for incomplete (not finalized) surveys on startup
        intCountMissing = Nz(DLookup("[RspnsID]", "tblSrvRspns", "[SurveyComplete] = " & False))
        If intCountMissing > 0 Then
            Select Case MsgBox("You have surveys that are not yet finalized." _
                               & vbCrLf & "" _
                               & vbCrLf & "Ok to open the first unfinished survey" _
                               & vbCrLf & "Cancel to disregard" _
                               , vbOKCancel Or vbQuestion Or vbDefaultButton1, "Survey Check")
                Case vbOK
                    strCriteria = intCountMissing
                    MsgBox strCriteria
                    With Me.RecordsetClone
                        .FindFirst strCriteria   <<<   INVALID ARGUMENT
                        If Not .NoMatch Then
                            Me.Bookmark = .Bookmark
                        End If
                    End With
                Case vbCancel
            End Select
        End If
    Not much hair left, been at this for hours and have been through many threads but can't for the life of me figure this out. I ultimately would like this to run when the form opens but for testing I have it on a button.

    Thanks for your help!
    Last edited by tuxalot; Dec 7 '10, 02:31 AM. Reason: clarify, code change
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Try:
    Code:
    Dim strCriteria As String
    Dim intCountMissing As Integer
    Dim rst As DAO.Recordset
      
    Set rst = Me.RecordsetClone
      
    'check for incomplete (not finalized) surveys on startup
    intCountMissing = DLookup("[RspnsID]", "tblSrvRspns", "[SurveyComplete] = False")
    
    If intCountMissing > 0 Then
      Select Case MsgBox("You have surveys that are not yet finalized." _
                          & vbCrLf & "" _
                          & vbCrLf & "Ok to open the first unfinished survey" _
                          & vbCrLf & "Cancel to disregard" _
                          , vbOKCancel + vbQuestion + vbDefaultButton1, "Survey Check")
        Case vbOK
          strCriteria = "[RspnsID] = " & intCountMissing
                 
            With rst
              .FindFirst strCriteria
                If Not .NoMatch Then
                  Me.Bookmark = .Bookmark
                End If
            End With
        Case vbCancel
      End Select
    End If

    Comment

    • tuxalot
      New Member
      • Feb 2009
      • 200

      #3
      Man, thanks for coming to my rescue again ADezii.

      Cheers!

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        That's what we are all here for (LOL).

        Comment

        Working...