Text Variable filter on a decimal

dabba23dabba23 Member Posts: 77
I have this Variable (AmountFilter) on a form that needs to used for filtering on a decimal field. The variable is a text string.

The Variable can for example contain following data:

> 100
100..200
100|200

etc.

How do I use this Variable to filter on a decimal field

I have tried with

setfilter("Amount (LCY)",'%1',AmountFilter)

but obviously I an error!

Ann

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try this
    SETFILTER("Amount (LCY)",AmountFilter);
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • dabba23dabba23 Member Posts: 77
    Thanks for that, but is it possible for you to explain me why that little difference?
  • JedrzejTJedrzejT Member Posts: 267
    CodeFilter:=A|B

    1 first scenario

    SETFILTER("code",CodeFilter);

    CodeFilter Is a Filter with sign like | &

    find rec with
    code:=A
    code:=B

    2. second scenario

    SETFILTER("Code",'%1',CodeFilter);

    CodeFilter is value of field without sign
    Nav try to set filter "Code" = exactly CodeFilter Value

    find rec with
    1 code:=A|B

    This syntax will cause error if codefilter Lenght > fieldlenght.
    Besides.. what record have 'A|B' in code field

    In your case:

    amountfilter:='100|200'
    setfilter("Amount (LCY)",'%1',AmountFilter)

    cause error because decimal can't have value '100|200'
    this is text or code value


    Regards
Sign In or Register to comment.