Results 1 to 3 of 3

Thread: ADO Recordset.Filter

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2010
    Posts
    16

    ADO Recordset.Filter

    Hi,

    I am getting the wrong number of records when I use the .filter on a Date field.

    rsInvoice.filter="Co_code='01'"
    rsInvoice.filter="Doc_date>=#01/04/2013# and Doc_date<=#31/03/2014#"

    Basically the earlier filters get reset.

    Is there anything that I am missing here?

    Any help / suggestions highly appreciated.

    dandy

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: ADO Recordset.Filter

    The filter isn't additive... so if you want to keep the first filter when you apply the second filter, you need to make is all one filter....

    Filter isn't anythign magicval... it's just a text property.... like the .Text property of a text box.

    Textbox1.Text = "Foo"
    TextBox1.Text = "Bar"

    What would you expect to be in TextBox1? "Bar" right? Filter is the same thing. Remember it keeps all of the records in it, it's simply filtering what you can & can't see.

    One additional thing... check your date formats... it may be misinterpreting the first one... I know I did... use a different format, one that can't be taken in an ambiguous manner... I like to use yyyy-mm-dd format... 2014-04-01 ... April 1st, 2014....
    if you use 01/04/2014 the database will interpret that as Jan 4, 2014, NOT April 1, 2014 ..... 31/01/2014 ... is only slightly less ambiguous, but only because there is no 31st month, so it's clear that's a day....


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    gibra
    Guest

    Re: ADO Recordset.Filter

    If you want to set both filters, then try this:

    Code:
    Dim sFilter As String 
    sFilter = "(Cod_code='01') " 
    sFilter = sFilter & " AND (Doc_date>=#01/04/2013# AND Doc_date<=#31/03/2014#)"
    rsInvoice.Filter = sFilter

Posting Permissions

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



Click Here to Expand Forum to Full Width