Results 1 to 5 of 5

Thread: My ADO Recordset Filter

  1. #1

    Thread Starter
    Addicted Member Smartacus's Avatar
    Join Date
    Oct 2009
    Location
    Deep South, USA
    Posts
    196

    My ADO Recordset Filter

    I am filling a LV based on the values passed using radio buttons after update to nFilter(INT).

    I am getting a mismatch and would like to figure this out. Basically what I am needing to do is compare the Archive Date Due on the column (ArchDateDue DateTime(8)) and compare them to display records that are between the given dates.

    Code:
    Private Sub FillArchiveDue(nFilter As Integer)
    lvwArchiveDue.ListItems.Clear
    
    RS(0).filter = "DATEDIFF(DD, ArchDateDue, CURRENT_TIMESTAMP) <= " & nFilter
     
    
        Do While Not RS(0).EOF
            With lvwArchiveDue.ListItems.Add(, "F" & RS(0)!id & "")
                .Text = RS(0)!id
                .SubItems(1) = RS(0)!id
                .SubItems(2) = RS(0)!clientid
                .SubItems(3) = RS(0)!clientname
                .SubItems(4) = RS(0)!DISC
                .SubItems(5) = Nz(RS(0)!ArchDateDue, #1/1/2000#)
                .SubItems(6) = Nz(RS(0)!ProgramNumber, 0)
    
            End With
            RS(0).MoveNext
            'Next row
        Loop
    
    RS(0).filter = adFilterNone
       
    End Sub
    SO far just errors: "Arguments are of the wrong type, are out of acceptable range, or are in conflict of one another"
    ***************************************************
    Smartacus comes packaged "As Is With No Warranty"

    ************* Useful Links ******************
    FAQs: Index / Database Development / .NET CodeBank /
    Before Posting Here...MSDN

    MZTools (I love this tool when using VB6 - Free) /

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: My ADO Recordset Filter

    I believe that the interval argument has to be enclosed in double quotes. Perhaps this might help:
    Code:
    RS(0).Filter =  "DATEDIFF(""dd"", ArchDateDue, CURRENT_TIMESTAMP) <= " & nFilter

  3. #3
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: My ADO Recordset Filter

    I've just done some Googling around and it looks like the Filter poperty does not support calculated values - the Filter is performed locally on the RecordSet rather than by the Database Engine.

    It looks as if you're restricted to Filters of the form FileldName-Operator-Value so you may have to re-query with the DateDiff within a WHERE clause. Even concatinating with AND and OR has restrictions as well.

    See here: http://docs.sun.com/source/817-2514-10/Ch11_ADO115.html for example

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: My ADO Recordset Filter

    You may also want to look at the .Find and .FindNext methods.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: My ADO Recordset Filter

    Since the Nz() function doesn't exist in VB6 this must be an Access question.

    In any case the Find method only allows searching based on a single column making it somewhat more restrictive than the Filter property.

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