PC Review


Reply
Thread Tools Rate Thread

Convert string value to numeric value

 
 
alhotch
Guest
Posts: n/a
 
      25th May 2010
I saw a post that showed how to convert from a number value to a string
value. But how about the other way ? Convert a string value to a number value.

Example, fieldA contains the text value "YES". fieldB is to contain the
numberic value of "1". How would one create a query that would accomplish
this task ?

"YES" would put the number one (1) in fieldB and "NO" would put the value of
two (2) in fieldB.
 
Reply With Quote
 
 
 
 
alhotch
Guest
Posts: n/a
 
      25th May 2010
Check that. I figured it out.

IIF[fieldA]="YES","1", IIF[fieldB]="NO","2",Null

This places the number one (1) in the "appended" field YesNo or the number
two (2) in the same field, depending on the values of fieldA or fieldB.

"alhotch" wrote:

> I saw a post that showed how to convert from a number value to a string
> value. But how about the other way ? Convert a string value to a number value.
>
> Example, fieldA contains the text value "YES". fieldB is to contain the
> numberic value of "1". How would one create a query that would accomplish
> this task ?
>
> "YES" would put the number one (1) in fieldB and "NO" would put the value of
> two (2) in fieldB.

 
Reply With Quote
 
Jeff Boyce
Guest
Posts: n/a
 
      25th May 2010
As written, your IFF() statement checks two different fields for values, not
one.

And by the way, if you already have a "YES", why do you (also) need a "1"?
You wouldn't need to store that "calculated value", you could just use a
(corrected) IIF() expression to calculate a "1" or a "2" on the fly...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"alhotch" <(E-Mail Removed)> wrote in message
news:3A16170A-6FD6-4AC2-852A-(E-Mail Removed)...
> Check that. I figured it out.
>
> IIF[fieldA]="YES","1", IIF[fieldB]="NO","2",Null
>
> This places the number one (1) in the "appended" field YesNo or the number
> two (2) in the same field, depending on the values of fieldA or fieldB.
>
> "alhotch" wrote:
>
>> I saw a post that showed how to convert from a number value to a string
>> value. But how about the other way ? Convert a string value to a number
>> value.
>>
>> Example, fieldA contains the text value "YES". fieldB is to contain the
>> numberic value of "1". How would one create a query that would accomplish
>> this task ?
>>
>> "YES" would put the number one (1) in fieldB and "NO" would put the value
>> of
>> two (2) in fieldB.



 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      26th May 2010
Do you want a number or a text string that consists of numbers?
IIF(FieldA="Yes",1,IIF(FieldA="No",2,Null))

As noted elsewhere, your expression does something different than the text
description you posted.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

alhotch wrote:
> Check that. I figured it out.
>
> IIF[fieldA]="YES","1", IIF[fieldB]="NO","2",Null
>
> This places the number one (1) in the "appended" field YesNo or the number
> two (2) in the same field, depending on the values of fieldA or fieldB.
>
> "alhotch" wrote:
>
>> I saw a post that showed how to convert from a number value to a string
>> value. But how about the other way ? Convert a string value to a number value.
>>
>> Example, fieldA contains the text value "YES". fieldB is to contain the
>> numberic value of "1". How would one create a query that would accomplish
>> this task ?
>>
>> "YES" would put the number one (1) in fieldB and "NO" would put the value of
>> two (2) in fieldB.

 
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
Convert string to Numeric in VB.net 2003 ? engteng Microsoft VB .NET 9 30th Sep 2008 10:24 PM
convert int to numeric (formatted) string raulavi Microsoft Dot NET 2 11th Mar 2008 02:42 PM
Convert String to Numeric Values JenISCM Microsoft Access 2 9th Jan 2008 06:41 PM
Convert a string value to numeric and sort mariomaf Microsoft Excel Programming 2 5th Jan 2006 09:56 AM
How do I convert a string to a numeric value in Access? =?Utf-8?B?S2lzaG1hdHVzaA==?= Microsoft Access Queries 1 4th Aug 2005 05:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:17 AM.