Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-07-16
8
Medium Priority
?
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 65

Accepted Solution

by:
rockiroads earned 280 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 120 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

730 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