Re: Map code to label in query

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: John Spencer (MVP) (spencer4_at_comcast.net)
Date: 07/16/04


Date: Thu, 15 Jul 2004 21:42:50 -0400

You can implement the suggestion given by Ted Allen and it will work, but in my
opinion you are almost always better off adding the translation table. It
becomes very easy to handle any new code values, just add one record to one
table. Or if someone decides that "Spouse" should be "Significant Other" or
"Life Partner" or "Dependent" should be "Child" or "Household Minor", again you
edit one record.

If you use the hard-coding method, you have to locate every instance where you
have coded this conversion and make the change. Plus if you end up with more
than 3 or 4 values, the code gets very cumbersome to read.

Just my thoughts, take them for what they cost you.

Ted Allen wrote:
>
> If you only have 3 codes, you can just use something like
> the following as the field source:
>
> Name: iif(Code = 1,"Member",iif(Code = 2,"Spouse",iif
> (Code = 3,"Dependent","")))
>
> HTH, Ted Allen
> >-----Original Message-----
> >I am running a query that groups an indicator code. I
> >would like to label the code. Here are the results of
> the
> >query:
> >
> >Code Sum
> > 1 3500.00
> > 2 2500.00
> > 3 1000.00
> >
> >The code field is grouped "Group by" in the query.
> >
> >I would like to map the code to an english name. Here
> is
> >what I would like to see:
> >
> >Code Sum Name
> > 1 3500.00 Member
> > 2 2500.00 Spouse
> > 3 1000.00 Dependent
> >
> >I could create a separate table with that identifies the
> >name for each code and then join to my original table
> but
> >I would like to avoid that if possible.
> >
> >Is there a way to do this in the query?
> >
> >Thanks in advance.
> >
> >Attila
> >
> >.
> >



Relevant Pages

  • Re: Finally which ORM tool?
    ... know that query expressions implicitly use lambda expressions. ... It's not a given there are lambda expressions involved. ... There will always be an expression tree if you implement IQueryable ... translation which uses lambda expressions, ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: IIF with multiple requirement
    ... Use the translation table in your select query as criteria on like this ... Run select query to verify results. ... i can't create each single order the a ship-to code. ... Also I have already got some SHIPTO in the SHIPTO1. ...
    (microsoft.public.access.queries)
  • RE: IIF with multiple requirement
    ... Use the translation table in your select query as criteria on like this ... Run select query to verify results. ... i can't create each single order the a ship-to code. ... Also I have already got some SHIPTO in the SHIPTO1. ...
    (microsoft.public.access.queries)
  • RE: IIF with multiple requirement
    ... I join the translation table with my other table on with criteria: ... Use the translation table in your select query as criteria on like this ... i can't create each single order the a ship-to code. ... Also I have already got some SHIPTO in the SHIPTO1. ...
    (microsoft.public.access.queries)
  • Re: SQL Query in Translation Function
    ... ICS Naming Standards, which holds the Arabic names and their English ... to an SQL Query which executes an SQL query on an ADODB recordset ... ' Lookup Arabic Value in ICS table and return English translation ...
    (microsoft.public.access.modulesdaovba)