MS Access Help!!!! - HotUKDeals
We use cookie files to improve site functionality and personalisation. By continuing to use HUKD, you accept our cookie and privacy policy.
Get the HUKD app free at Google Play

Search Error

An error occurred when searching, please try again!

Login / Sign UpSubmit

MS Access Help!!!!

Abz Avatar
6y, 5m agoPosted 6 years, 5 months ago
Afternoon All,

I wonder if any MS Access experts could help me out please.

I have a table which has a list of customers, and in that table there are 3 columns...Customer ID, Customer Group and Customer Name....Now what i am trying to do is a query to is to pull all the customer groups and if thats null then pull the customer name...

But i want is the data to sit in one column...no two sperate ones when running the queries!
Abz Avatar
6y, 5m agoPosted 6 years, 5 months ago
Options

All Comments

(7) Jump to unreadPost a comment
Comments/page:
1 Like #1
Hi,

I assumed your table was called [Customers] & the heading of the resultant column was [Customer]

SELECT
IIf(IsNull([Customer Group]),[Customer Name],[Customer Group]) AS [Customer]
FROM
[Customers]


BFN,

fp.
1 Like #2
You will need 2 queries and join them as a union, something like this:

select customer_group as customer
from table
where customer_group is not null
UNION
select customer_name as customer
from table
where customer_group is null
#3
fanpages;8931686
Hi,

I assumed your table was called [Customers] & the heading of the resultant column was [Customer]

SELECT
IIf(IsNull([Customer Group]),[Customer Name],[Customer Group]) AS [Customer]
FROM
[Customers]


BFN,

fp.


Op this is probably the best method so I would go for this :thumbsup:
#4
Thanks people....i just figured it out...

I used the following:

IIF([Customer Name] Is Null, [Customer Group],[Customer Name]) As Customer

that worked a treat.....Thanks for you help!
#5
Abz
Thanks people....i just figured it out...

I used the following:

IIF([Customer Name] Is Null, [Customer Group],[Customer Name]) As Customer

that worked a treat.....Thanks for you help!


But that is the converse of what you asked for.

You wished to "...pull all the customer groups and if thats null then pull the customer name...".

Using your suggestion what you have is something that provides the [Customer Name] in preference, & the [Customer Group] if the Name is 'Null'.

Thanks for the "rep" in any case.

BFN,

fp.
#6
fanpages
But that is the converse of what you asked for.

You wished to "...pull all the customer groups and if thats null then pull the customer name...".

Using your suggestion what you have is something that provides the [Customer Name] in preference, & the [Customer Group] if the Name is 'Null'.

Thanks for the "rep" in any case.

BFN,

fp.



Correct....But Im not using a customer table...i was just giving the example of a customer table as it was easier to get point accross of what i was trying to do....

I guess in my reply/opening post i got the fields the wrong way round...but the main thing is I got what i needed...

so thanks :thumbsup:
banned#7
Spriggan;8931712
You will need 2 queries and join them as a union, something like this:

select customer_group as customer
from table
where customer_group is not null
UNION
select customer_name as customer
from table
where customer_group is null

quite possibly the worst SQL query I have ever seen to retrieve data from a single table! :w00t:

Post a Comment

You don't need an account to leave a comment. Just enter your email address. We'll keep it private.

...OR log in with your social account

...OR comment using your social account

Thanks for your comment! Keep it up!
We just need to have a quick look and it will be live soon.
The community is happy to hear your opinion! Keep contributing!