Solved

problem with Filter property in ADO......?

Posted on 2006-07-16
8
321 Views
Last Modified: 2008-02-01
hi
iwant to filter my data depend on date and cunsumerFamily in the following way:
for example                     month=2 AND cunsumerFamily=X
 another example             year=1985 AND  cunsumerFamily=X
but i dont know how to write a sql statement for ADO filter property that contained both date and consumerFamily with conditions above.
any help will be appreciated
thanks bayat
vb6
ado datacontrol
access 2000 database
0
Comment
Question by:sdf145
  • 3
  • 3
  • 2
8 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17119897
well u could do one of two ways

Actually specify this in your sql
e.g.

sSql = "SELECT * FROM Table Where Month=2 AND CunsumerFamily='X'"

then use this sql when u open the recordset

or use the recordset filter

rs.Find "Month=2 AND CunsumerFamily='X'"

0
 
LVL 44

Expert Comment

by:bruintje
ID: 17119899
Hi sdf145,
----------

did you try

rst.Filter = "Month=2 And ConsumerFamily <> 'X'"

----------
bruintje
share what you know, learn what you don't
0
 

Author Comment

by:sdf145
ID: 17119991
it is not answer i am looking for
date field in database is in this format YYYY/MM/DD
but im looking for YYYY or MM
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 65

Accepted Solution

by:
rockiroads earned 70 total points
ID: 17120008
try this then

Year(<datefld>)
or
Month(<datefld>)


Use can also use Format or Datepart I think

Format(<datefld>,"YYYY")

Datepart("yyyy",<datefld>)

0
 
LVL 44

Assisted Solution

by:bruintje
bruintje earned 30 total points
ID: 17120020
rst.Filter = "MONTH(MyDate)=2 And ConsumerFamily <> 'X'"
OR
rst.Filter = "YEAR(MyDate)=1998 And ConsumerFamily <> 'X'"

but i'm not sure if you can do that in a ado filter

else you would need to do it in the SQL select statement
0
 
LVL 44

Expert Comment

by:bruintje
ID: 17120022
:)
0
 

Author Comment

by:sdf145
ID: 17120053
thank u for ur attempt
u are perfect
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17126984
glad your sorted and thanks
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question