Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing and "translating" numbers

Status
Not open for further replies.

SalGal

Technical User
Nov 22, 2002
24
US
Two parts to this question, but first background:

Access 2003
Linked table (ODBC) with a 2-character text field
Values stored in the field are numbers
The first number represents relationship: mother, father, grandmother, husband, wife, other
The second number is a modifier, if you will, of the relationship - natural, step, foster, in-law

Field values can look like this:
21
11
2
8
<blank>
22
7

Problem 1: Sometimes there is one number in the field, sometimes two. This presents a problem when trying to parse the second number because Right([field],1) only works correctly if there are 2 numbers in the field. I know I need some sort of If/then type statement to evaluate whether there is one or two numbers in the field, but I can't seem to get my brain around how to do that.

Problem 2: Then, once the number(s) are separated, I need to assign the text values to them. I'm pretty sure I have this part figured out, but isn't working because of Problem #1.

Appreciate any suggestions. Thanks!
 
Assuming that a single character (such as 2) would always be read as 2 blank and never blank 2, you could convert everything to a two character field like this:

Code:
Left(Trim(Nz([Field Name], "")) & "00", 2)

Your values would be converted:

21 21
11 11
2 20
8 80
<blank> 00
22 22
7 70

 
Randy, you're far away from JetSQL syntax ...
 
Axworthy - so close!

Unfortunately, "0" has an assigned value (spouse) for the first character, so I can't convert the blanks in the first space to zeros; I can use that logic for the second character since it does not use "0" as a possible values.

I'll continue to play with it. . . thanks.
 
Replace this:
Code:
Left(Trim(Nz([Field Name], "")) & "00", 2)
with this:
Code:
Left(Trim([Field Name] & "") & "  ", 2)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top