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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iff 102 then change it to 0102

Status
Not open for further replies.

TJVFree

Technical User
Nov 22, 2010
236
US
What would be the easyest why for this statment to be layed out

=IIf(([org_code]) = 102,"0102" ([org_code]), 0)

Thank you for your time and help
 
=IIf ([org_code]=102,"0102",0)

is [org_code] numeric or string?
 
This is the message I get:

The expression you entered has an invalid. (dot) or ! operator or invalid parentheses

You may have entered an invalid identifier or typed parentheses following the null constant

I'm not sure what that means
 
In that case try

IIf ([org_code]="102","0102","somthing else")
 
or to keep the original value as is...

IIf ([org_code]="102","0102",[org_code])
 
Your original IIF is invalid because
Code:
=IIf(([org_code]) = 102,[red]"0102"[COLOR=black yellow] [/color]([org_code])[/red], 0)
There is no operator between "0102" and ([org_code])

Since [org_code] is text, you may need
Code:
=IIf([org_code] = "102", "0102", [org_code])
 
for some reson, this still isnt working. it still shows 102, and Ideas?
 

Just a guess here:
Code:
=IIf([blue]Val([org_code]) > 0[/blue], [red]Format([org_code], "000")[/red], [green]"0"[/green])

You may test separately [blue]BLUE[/blue] and [red]RED[/red] parts of this code to make sure it works the way you want.


Have fun.

---- Andy
 

CoreyVI,

Where are you trying to enter this statement?
Please provide the entire code.


Randy
 



Why not simply...
Code:
Format(CInt([org_code]), "0000")
assuming that ALL the ID strings need to be 4 digits long.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
some are five and six. but thank you for this information

Coery
 

You still did not answer Randy's request:
Where are you trying to enter this statement?
Please provide the entire code.

Have fun.

---- Andy
 
This might work:

IIf(Val([Org_Code])>0,'0' & [Org_Code],[Org_Code])
 
Lots of assumptions and guesses in this thread.

CoreyVl,
Can you provide some information regarding the scope of this question? Is this only for Org_Codes with a value of "102" or do you wish to transform many different values?

If you want to transform many different values, please provide a "rule" and a variety of values with the expected results.

Also, is this in a code module, control source, query, ...?

Do you want to update a value or simply display the transformed format?


Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top