Skip to main content
Solved

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


Forum|alt.badge.img

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([AMProdItem.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!

Best answer by miguel80

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

 

Sorry one extra )

View original
Did this topic help you find an answer to your question?

4 replies

miguel80
Semi-Pro I
Forum|alt.badge.img+1
  • Semi-Pro I
  • 68 replies
  • July 2, 2024

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([AMProdItem.InventoryID],2)='-C'), True, False)

 

Hope this works


Forum|alt.badge.img
  • Author
  • Freshman II
  • 129 replies
  • July 2, 2024
miguel80 wrote:

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([AMProdItem.InventoryID],2)='-C'), True, False)

 

Hope this works

Thanks Miguel!

I receive a Syntax error:
 

 


miguel80
Semi-Pro I
Forum|alt.badge.img+1
  • Semi-Pro I
  • 68 replies
  • Answer
  • July 2, 2024

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

 

Sorry one extra )


Forum|alt.badge.img
  • Author
  • Freshman II
  • 129 replies
  • July 2, 2024
miguel80 wrote:

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

 

Sorry one extra )

That did it, thank you!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings