Consulting

Results 1 to 6 of 6

Thread: issue with .filter on a recordset

  1. #1

    issue with .filter on a recordset

    getting a run-time error 3464
    "data type mismatch in criteria expression"
    flagged on line Set rsFiltered = .OpenRecordset
    first debug.print recordcount works fine and # is correct.

    trying to automate the filtering of the rs.
    have hard coded 204178 as my filter for job field.
    this should return a record count of 7
    can't get past the error.

    Neil



    Public Sub seqissue()
    
    
    Dim rs As Recordset
    Dim rsFiltered As Recordset
    Dim strSQL As String
    
    
    strSQL = "SELECT dbo_Job1.Job, dbo_Job_Operation1.Sequence, dbo_Job_Operation1.Work_Center, dbo_Job_Operation1.Status " _
           & "FROM dbo_Job1 INNER JOIN dbo_Job_Operation1 ON dbo_Job1.Job = dbo_Job_Operation1.Job " _
           & "GROUP BY dbo_Job1.Job, dbo_Job_Operation1.Sequence, dbo_Job_Operation1.Work_Center, dbo_Job_Operation1.Status, dbo_Job1.Status " _
           & "HAVING (((dbo_Job1.Status)='active')); " _
        
    Set rs = CurrentDb.OpenRecordset(strSQL)
    rs.MoveLast
    rs.MoveFirst
    
    
        With rs
            Debug.Print .RecordCount
            .Filter = "[Job]=204178"
            Set rsFiltered = .OpenRecordset
            rsFiltered.MoveLast
            rsFiltered.MoveFirst
            Debug.Print rsFiltered.RecordCount
            .Close
        End With
    
    
    Set rs = Nothing
    
    
    End Sub
    Last edited by Tommy; 10-23-2013 at 08:51 AM. Reason: Added code tags: Tommy

  2. #2
    VBAX Contributor
    Joined
    Oct 2011
    Location
    Concord, California
    Posts
    101
    Location
    Have you tried:

    Dim lngJobNo as Long

    then
    .Filter="[Job]=" & lngJobNo

  3. #3
    Good job i appreciate your work.because I have same problem but you post solve my problem.

  4. #4
    VBAX Contributor
    Joined
    Oct 2011
    Location
    Concord, California
    Posts
    101
    Location
    Glad to contribute to this website with useful information.

  5. #5
    VBAX Newbie
    Joined
    Nov 2013
    Posts
    2
    Location
    I am interested in this topic and would like to find out some more information as my friend need information on this topic. Do you have any other articles about this?
    Eventually i am come here and want to say you that thanks for sharing your concept regarding the post. I am also feeling that this is one of the good posts.
    I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will locate that extremely useful

  6. #6
    VBAX Newbie
    Joined
    Nov 2013
    Posts
    2
    Location
    Quote Originally Posted by shahid11 View Post
    I am interested in this topic and would like to find out some more information as my friend need information on this topic. Do you have any other articles about this?
    Eventually i am come here and want to say you that thanks for sharing your concept regarding the post. I am also feeling that this is one of the good posts.
    I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will locate that extremely useful
    Nice post.............

Posting Permissions

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