Concatenate number and text

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jgscott3@bellsouth.net

    Concatenate number and text

    All,

    I have the following expression in a query:

    Switch([Code 5 Digits]>=10121 And [Code 5 Digits]<=10135,[Code 5
    Digits]&"xxx")

    (There are other expresions within Switch, but this is the one in
    question.)

    I need to evaluate [Code 5 Digits] as a number, but then concatenate
    with the text "xxx" if it meets the conditions.

    Thanks.

    JG Scott

  • Nancy Moon

    #2
    Re: Concatenate number and text


    What happens when [Code 5 Digits] is null or is not between or equal
    the limits?

    In a Access sql query I would try IIF() which has true AND false
    parameters.

    IIf(expr, truepart, falsepart)

    IIf([Code 5 Digits]>=10121 And [Code 5 Digits]<=10135, [Code 5 Digits]
    & "xxx", "failed")

    Nancy

    On 31 Dec 2006 12:16:44 -0800, "jgscott3@bells outh.net"
    <jgscott3@bells outh.netwrote:
    >All,
    >
    >I have the following expression in a query:
    >
    >Switch([Code 5 Digits]>=10121 And [Code 5 Digits]<=10135,[Code 5
    >Digits]&"xxx")
    >
    >(There are other expresions within Switch, but this is the one in
    >question.)
    >
    >I need to evaluate [Code 5 Digits] as a number, but then concatenate
    >with the text "xxx" if it meets the conditions.
    >
    >Thanks.
    >
    >JG Scott

    Comment

    • '69 Camaro

      #3
      Re: Concatenate number and text

      Hi, JG.
      I need to evaluate [Code 5 Digits] as a number, but then concatenate
      with the text "xxx" if it meets the conditions.
      Use the Val( ) function to evaluate a string as a number. Try (watch out for
      word wrap):

      Switch(Val([Code 5 Digits]) >=10121 And Val([Code 5 Digits]) <=10135, [Code 5
      Digits] & "xxx")

      HTH.
      Gunny

      See http://www.QBuilt.com for all your database needs.
      See http://www.Access.QBui lt.com for Microsoft Access tips and tutorials.
      http://www.Access.QBui lt.com/html/expert_contribu tors2.html for contact info.


      <jgscott3@bells outh.netwrote in message
      news:1167596204 .665080.166540@ s34g2000cwa.goo glegroups.com.. .
      All,
      >
      I have the following expression in a query:
      >
      Switch([Code 5 Digits]>=10121 And [Code 5 Digits]<=10135,[Code 5
      Digits]&"xxx")
      >
      (There are other expresions within Switch, but this is the one in
      question.)
      >
      I need to evaluate [Code 5 Digits] as a number, but then concatenate
      with the text "xxx" if it meets the conditions.
      >
      Thanks.
      >
      JG Scott
      >

      Comment

      • Nancy Moon

        #4
        Re: Concatenate number and text

        I agree with Gunny that you may need to ensure the [Code 5 Digits] is
        evaluated as a number and you could use Val([Code 5 Digits]) or
        CInt([Code 5 Digits]) to do this.

        You could use Switch to look at another range of numbers by adding
        more arguments. Like this:
        Switch(
        [Code 5 Digits]>=10121 And [Code 5 Digits]<=10135,[Code 5
        Digits]&"xxx",
        [Code 5 Digits]>10135,"is larger",
        [Code 5 Digits]<10121,"is smaller")

        Just make sure the ranges used do not overlap <grin>

        Nancy

        On 31 Dec 2006 12:16:44 -0800, "jgscott3@bells outh.net"
        <jgscott3@bells outh.netwrote:
        >All,
        >
        >I have the following expression in a query:
        >
        >Switch([Code 5 Digits]>=10121 And [Code 5 Digits]<=10135,[Code 5
        >Digits]&"xxx")
        >
        >(There are other expresions within Switch, but this is the one in
        >question.)
        >
        >I need to evaluate [Code 5 Digits] as a number, but then concatenate
        >with the text "xxx" if it meets the conditions.
        >
        >Thanks.
        >
        >JG Scott

        Comment

        Working...