Expresion help!

G

Guest

I have a query with 2 fields. Field one contains either a number or words.
Then I have another field that contains just words.

Example:

Field 1 Field 2

Word 1 Word A
1234 Word B
5678 Word C
Word 2 Word A
Word 1 Word C

I need an expresion that looks for a record that contains a number, and if
it finds it, I want to populate field 2, if it does not find a number (it is
a word) I want to populate field 1.

Based on the example above, after running the query the output would be the
following:

Expr1
Word 1
Word B
Word C
Word 1
Word 2

Is there an expresion that can do that?
 
G

Guest

I have a query with 2 fields. Field one contains either a number or words.
Then I have another field that contains just words.

Example:

Field 1 Field 2

Word 1 Word A
1234 Word B
5678 Word C
Word 2 Word A
Word 1 Word C

I need an expresion that looks for a record that contains a number on field 1, and if it finds it, I want to populate field 2, if it does not find a number (it is
a word) I want to populate field 1.

Based on the example above, after running the query the output would be the
following:

Expr1
Word 1
Word B
Word C
Word 2
Word 1

Is there an expresion that can do that?
 
G

Guest

Thanks Rob. It almost worked. Field 1 contains also blank records, example:

Field 1 Field 2

Word 1 Word A
1234 Word B
(blank record) Wrod B
5678 Word C
(blank record) Word C
Word 2 Word A
Word 1 Word C

I thought that since the blank record is not a number, it would populate
field 2, but it doesn't. It populates Field 1 which is blank. I need a
formula that when searching field 1, if it finds a number or a blank record,
to populate field 2, if it finds a word, to populate field 1.

The result in the example above should be:

Expr1
Word 1
Word B
Word B
Word C
Word C
Word 2
Word 1

Can you tell me the expression?

Thanks


Rob Parker said:
Expr1: IIf(IsNumeric([Field1]),[Field2],[Field1])

HTH,

Rob
 
J

John Spencer

That's strange it appears to work for me.

I guess you could try the following.

Expr1: IIf(IsNumeric([Field1]),[Field2],Nz([Field1],[Field2]))

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Alexandra504 said:
Thanks Rob. It almost worked. Field 1 contains also blank records,
example:

Field 1 Field 2

Word 1 Word A
1234 Word B
(blank record) Wrod B
5678 Word C
(blank record) Word C
Word 2 Word A
Word 1 Word C

I thought that since the blank record is not a number, it would populate
field 2, but it doesn't. It populates Field 1 which is blank. I need a
formula that when searching field 1, if it finds a number or a blank
record,
to populate field 2, if it finds a word, to populate field 1.

The result in the example above should be:

Expr1
Word 1
Word B
Word B
Word C
Word C
Word 2
Word 1

Can you tell me the expression?

Thanks


Rob Parker said:
Expr1: IIf(IsNumeric([Field1]),[Field2],[Field1])

HTH,

Rob

Alexandra504 said:
I have a query with 2 fields. Field one contains either a number or
words.
Then I have another field that contains just words.

Example:

Field 1 Field 2

Word 1 Word A
1234 Word B
5678 Word C
Word 2 Word A
Word 1 Word C

I need an expresion that looks for the records that contains a number
in
field number 1, and if it finds it, I want to populate field 2, if it
does not find a number (it is a word) I want to populate field 1.

Based on the example above, after running the query the output would
be
the
following:

Expr1
Word 1
Word B
Word C
Word 2
Word 1

Is there an expresion that can do that?
 

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