Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-02-2009, 03:02 AM   #1
sx1
Registered User
 
Join Date: Jun 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sx1 is on a distinguished road
[Urgent] Filtering and saving multiple records in multiple columns.

Sorry about my first post being like this,but its sort of urgent. Having looked all over the internet this afternoon, I am quite tired and frustrated. And I need this for office tomm morning.

So i have a table with multiple columns. I think its better i explain by an example.

Eg:

C1 C2
1 X
1 X
2 X
2 Y
3 Y
4 Y
4 Y
5 X
5 X
5 X
.....
30,000

I need to filter C1 so that it will have both X & Y.(C2 is always X or Y). So in this case I need to get only 2 as it has both X & Y. So it shoudl appear like this:

C1 C2
2 X
2 Y

Then I need to export this to excel.

I tried to run the query WHERE C2="X" or C2="Y". But it hangs up,maybe bcos there are 4 more columns and I have filtered them, just can't filter this part.

Oh my knowledge level of access is average to slightly above avg.

Thank you very much for your help.

sx1 is offline   Reply With Quote
Old 06-02-2009, 04:08 AM   #2
khawar
AWF VIP
 
khawar's Avatar
 
Join Date: Oct 2006
Location: Islamabad, Pakistan
Posts: 870
Thanks: 0
Thanked 42 Times in 15 Posts
khawar will become famous soon enough khawar will become famous soon enough
Re: [Urgent] Filtering and saving multiple records in multiple columns.

Use This sql
Select C1,C2 from Yourtablename where c1=2
__________________
Khawar
khawar is offline   Reply With Quote
Old 06-02-2009, 04:14 AM   #3
neileg
AWF VIP
 
neileg's Avatar
 
Join Date: Dec 2002
Location: Newcastle, England
Posts: 5,975
Thanks: 0
Thanked 8 Times in 8 Posts
neileg has a spectacular aura about neileg has a spectacular aura about
Re: [Urgent] Filtering and saving multiple records in multiple columns.

Two queries:
Code:
SELECT DISTINCT MyTable.c1, MyTable.c2
FROM MyTable;
Code:
SELECT Query1.c1, Count(Query1.c2) AS CountOfc2
FROM Query1
GROUP BY Query1.c1
HAVING (((Count(Query1.c2))=2));
You could write this all in one query but two will work the same.

__________________
You can't always get what you want, but if you try sometimes you may just get what you need - Rolling Stones

Cheers, Neil
neileg is offline   Reply With Quote
Old 06-02-2009, 04:17 AM   #4
khawar
AWF VIP
 
khawar's Avatar
 
Join Date: Oct 2006
Location: Islamabad, Pakistan
Posts: 870
Thanks: 0
Thanked 42 Times in 15 Posts
khawar will become famous soon enough khawar will become famous soon enough
Re: [Urgent] Filtering and saving multiple records in multiple columns.

Sorry i didnt read it properly Neileg's solution is perfect
__________________
Khawar
khawar is offline   Reply With Quote
Old 06-02-2009, 03:50 PM   #5
sx1
Registered User
 
Join Date: Jun 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sx1 is on a distinguished road
Re: [Urgent] Filtering and saving multiple records in multiple columns.

Thank You very much for your reply!
But a stupid question,what exactly is Query1 here?

Would it be the X & Y's? If so wouldn't there be a Query2 too?
sx1 is offline   Reply With Quote
Old 06-02-2009, 06:06 PM   #6
sx1
Registered User
 
Join Date: Jun 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sx1 is on a distinguished road
Re: [Urgent] Filtering and saving multiple records in multiple columns.

Sorry guys have to bump this. I need to get this thing done today.

Is query1 the name of the table or X/Y?
sx1 is offline   Reply With Quote
Old 06-02-2009, 08:53 PM   #7
khawar
AWF VIP
 
khawar's Avatar
 
Join Date: Oct 2006
Location: Islamabad, Pakistan
Posts: 870
Thanks: 0
Thanked 42 Times in 15 Posts
khawar will become famous soon enough khawar will become famous soon enough
Re: [Urgent] Filtering and saving multiple records in multiple columns.

two queries are suggested to you query1 will be the name of first query whatever name you give it replace query1 with that name

__________________
Khawar
khawar is offline   Reply With Quote
Old 06-02-2009, 09:27 PM   #8
sx1
Registered User
 
Join Date: Jun 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sx1 is on a distinguished road
Re: [Urgent] Filtering and saving multiple records in multiple columns.

How do i write two queries?
sx1 is offline   Reply With Quote
Old 06-02-2009, 09:41 PM   #9
khawar
AWF VIP
 
khawar's Avatar
 
Join Date: Oct 2006
Location: Islamabad, Pakistan
Posts: 870
Thanks: 0
Thanked 42 Times in 15 Posts
khawar will become famous soon enough khawar will become famous soon enough
Re: [Urgent] Filtering and saving multiple records in multiple columns.

Use the solution given to you by Neileg Paste the sql in the sql view of query
__________________
Khawar
khawar is offline   Reply With Quote
Old 06-03-2009, 12:37 AM   #10
neileg
AWF VIP
 
neileg's Avatar
 
Join Date: Dec 2002
Location: Newcastle, England
Posts: 5,975
Thanks: 0
Thanked 8 Times in 8 Posts
neileg has a spectacular aura about neileg has a spectacular aura about
Re: [Urgent] Filtering and saving multiple records in multiple columns.

Quote:
Originally Posted by sx1 View Post
How do i write two queries?


Sorry, but this is very basic stuff. Have you used Access at all before?

__________________
You can't always get what you want, but if you try sometimes you may just get what you need - Rolling Stones

Cheers, Neil
neileg is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 05:41 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World