|
-
Jan 4th, 2011, 01:47 AM
#1
Thread Starter
Addicted Member
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"
-
Jan 4th, 2011, 07:11 AM
#2
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
-
Jan 4th, 2011, 07:59 AM
#3
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
-
Jan 4th, 2011, 08:02 PM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 4th, 2011, 09:12 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|