Solved

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

Posted on 2006-07-16
8
324 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month6 days, 22 hours left to enroll

622 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