Skip to main content
Solved

Visibility Expression -- check for character(s) at the end of a string

  • 2 July 2024
  • 4 replies
  • 27 views

Hi all, I’m creating something in Report Designer and I need to turn on the visibility of a text field based on Inventory ID. I have something like this:

 

IIf(InStr(tAMProdItem.InventoryID], '-C') > 0, True, False)

 

So that visibility expression is saying ‘if the ID contains “-C” then display the text box’

The issue is that the -C we want to check for is at the end of the InventoryID -- but we will many time have a multi-hyphenated Inventory ID where “-C” exists in the middle of the ID. We don’t want to check for -C > 0, we want to only check for -C at the end of the string.

How do I do this? I’m assuming I have to use some sort of Index but unsure how to do it. Thank you!

Hi!

If you wish to look for it at the end of the field you should try “Right()” so that you take the last 2 characters and compare them with “-C”.

 

IIF(Right(IAMProdItem.InventoryID],2)='-C'), True, False)

 

Hope this works


Hi!

If you wish to look for it at the end of the field you should try “Right()” so that you take the last 2 characters and compare them with “-C”.

 

IIF(Right(IAMProdItem.InventoryID],2)='-C'), True, False)

 

Hope this works

Thanks Miguel!

I receive a Syntax error:
 

 


IIF(Right([AMProdItem.InventoryID],2)='-C', True, False)

 

Sorry one extra )


IIF(Right([AMProdItem.InventoryID],2)='-C', True, False)

 

Sorry one extra )

That did it, thank you!


Reply