Skip to main content
Answer

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

  • July 2, 2024
  • 4 replies
  • 124 views

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 )

4 replies

miguel80
Semi-Pro III
Forum|alt.badge.img+3
  • Semi-Pro III
  • 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
  • Jr Varsity II
  • 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

Thanks Miguel!

I receive a Syntax error:
 

 


miguel80
Semi-Pro III
Forum|alt.badge.img+3
  • Semi-Pro III
  • Answer
  • July 2, 2024

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

 

Sorry one extra )


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • July 2, 2024

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

 

Sorry one extra )

That did it, thank you!