#Error in query

C

Carlos

Hello,

I have a table R,

ID as number
T as text

| ID | T |
| 1 | A01 |
| 2 | CEE |
| 3 | Z33 |

if the two right characters is numeric return numeric value else the two
right characters , in this example

| ID | T |
| 1 | 1 |
| 2 | EE |
| 3 | 33 |

i try this query:

SELECT ID, IIF(IsError(Right(T,2) *1),Right(T,2) ,Right(T,2) *1) FROM R

and the query not trap the error, it is possible get this.

thank's
 
J

John W. Vinson/MVP

Carlos said:
Hello,

I have a table R,

ID as number
T as text

| ID | T |
| 1 | A01 |
| 2 | CEE |
| 3 | Z33 |

if the two right characters is numeric return numeric value else the two
right characters , in this example

| ID | T |
| 1 | 1 |
| 2 | EE |
| 3 | 33 |

If the number can never be zero, try

IIF(Val(Right([T], 2) = 0, Right([T], 2), Val(Right(T), 2))

However, since you're allowing a Text value to be a valid result, the field
will be of Text datatype in any case. You CANNOT have a field which contains
text in a Number datatype.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top