Expression Help

mlr0911

Registered User.
Local time
Today, 01:18
Joined
Oct 27, 2006
Messages
155
I have the following expression:

expr4: IIf(InStr([expr3],")")>0,[expr3],[tick])

The above expression is returning this result:

TM)

How can I write an expression that would remove the ")"? I can't use the left function because the field varies in size (I've tried).

I have tried :

expr4: IIf(InStr([expr3],")")>0,[expr3]-1,[tick])

But this doesn't work

Thanks for your help.
 
If it's always at the end, you can use the Left function, using Len([expr3])-1 for the length argument. You could also use the Replace function.
 
expr4: IIf(InStr([expr3],")")>0,[expr3],[tick])

The above expression is returning this result:

TM)

How can I write an expression that would remove the ")"?
It might help if you could read in words what you are asking the program for by writing the above expression. It says:

If an outer parenthesis ")" exists in the string "[expr3]", then give me the "[expr3]" string as the return value. If the parenthesis character is not in the string (e.g. Instr() value = 0, or has no value), then give me the value "[tick]"

Is this what you meant to say? It is what you are saying, and that means that your original value "[expr3]" has an outer parenthesis character in it (at position 3)!!
 
Correct, but how can I say take Expr3 -1 to take the ")" out to only get the value?

Thanks
 
Correct, but how can I say take Expr3 -1 to take the ")" out to only get the value?

Thanks
Use this...
Code:
IIf((InStr([expr3],")")-1)>0,[expr3],[tick])

Sorry, not the above. Use the following code instead (to get the output without the ")")...
Code:
IIf(InStr([expr3],")")>0,((Left([expr3], InStr([expr3],")"))-1),[tick])
Sorry for the error in the first statement!!
 
If all you want to do is get rid of a closing parenthesis then you could use the replace function:

Replace ( [tick], ")", "")
 

Users who are viewing this thread

Back
Top Bottom