By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,397 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,397 IT Pros & Developers. It's quick & easy.

Concatenate number and text

P: n/a
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

Dec 31 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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, "jg******@bellsouth.net"
<jg******@bellsouth.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
Dec 31 '06 #2

P: n/a
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.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.
<jg******@bellsouth.netwrote in message
news:11**********************@s34g2000cwa.googlegr oups.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

Dec 31 '06 #3

P: n/a
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, "jg******@bellsouth.net"
<jg******@bellsouth.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
Jan 2 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.