PC Review


Reply
Thread Tools Rate Thread

How to Combine Four Fields into One with a Query

 
 
doyle60@aol.com
Guest
Posts: n/a
 
      3rd Feb 2005
I have a query that has four columns in it, along with others, that I
need to reduce into one.

The data could look like this:

PL1 PL2 PL3 PL4
20P 20P
40P
50P 50P 50P
30P 30P
(Could be null)
40P
10P

That is, each record will only have one value, never two different ones
in each field.

But I need a field to combine them into one. I want to get the PLAdj
field below:

PL1 PL2 PL3 PL4 PLAdj
20P 20P 20P
40P 40P
50P 50P 50P 50P
30P 30P 30P
(Should be null)
40P 40P
10P 10P

Nesting IIf statements would be a little much. Is there a function for
this type of thing?

Thanks,

Matt

 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      3rd Feb 2005
On 3 Feb 2005 07:50:59 -0800, "(E-Mail Removed)" <(E-Mail Removed)>
wrote:

>I have a query that has four columns in it, along with others, that I
>need to reduce into one.
>
>The data could look like this:
>
>PL1 PL2 PL3 PL4
>20P 20P
> 40P

....
>Nesting IIf statements would be a little much. Is there a function for
>this type of thing?


The Switch() function can be used here:

PLAdj: Switch(Not IsNull([PL1]), [PL1], Not IsNull([PL2]), [PL2], Not
IsNull([PL3]), [PL3], Not IsNull([PL4]), [PL4], True, Null)

either as a calculated field or in an Update query if you actually add
the PLAdj field to your table.

This might be a good idea - these four fields are improperly
normalized on two counts already!

John W. Vinson[MVP]
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combine two fields in a query to get a unique third one. Frank Martin Microsoft Access Queries 4 9th Oct 2009 07:12 AM
How do I combine data from two fields into one using a query? =?Utf-8?B?dGhqb2Zl?= Microsoft Access Queries 6 19th Sep 2005 05:07 AM
Combine 2 fields into 1 via SQL query amelia Microsoft Access Queries 2 27th Sep 2004 08:43 AM
how to combine fields on a form in a query as criteria? Henro Microsoft Access Getting Started 3 8th Jun 2004 03:50 PM
Combine Table Fields In Query JCrowe Microsoft Access 1 16th Apr 2004 08:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:26 PM.