Solved

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

Posted on 2006-07-16
8
323 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

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!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

710 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