View Single Post
  #4  
Old May 26th, 2010, 01:47 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Convert string value to numeric value

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.