0

select do' coding issue

I would be very grateful for somebody's help with this little issue...

 

I am trying to set a field's value (i.e. the 'Price' field) by using a set of statements from 'switch do' coding, but trying to use variables as case conditions , rather than testing using literal values.... 

Table1 contains an itemcode, and 6 fields (which are 3 pairs of qty/value). these represent qty breaks/prices. The actual quantities in these fields are 10, 20, and 30. 

I have setup a 'Sales' table/form for testing containing (and this table has a reference to Table1)

1. a 'Code' field in which I enter a code. Trigger code runs and retrieves the qty/prices fields information from Table1 (above) and sets the variables PBQty1, PBVal1, PBQty2, PBVal2, PBQty3, PBVal3 with their values.

 

let InputCode := Code;

let PBQty1 := first((select Table1)[ItemCode = InputCode].FirstQty);

let PBVal1 := first((select Table1)[ItemCode = InputCode].FirstValue);

let PBQty2 := first((select Table1)[ItemCode = InputCode].SecondQty);

let PBVal2 := first((select Table1)[ItemCode = InputCode].SecondValue);

let PBQty3 := first((select Table1)[ItemCode = InputCode].ThirdQty);

let PBVal3 := first((select Table1)[ItemCode = InputCode].ThirdValue);

 

2. Now, for the Sales table/form - I enter a specific value (test value) of 10, 20, or 30 in the 'Quantity' field. Trigger code should run testing the quantity just entered against a set of conditions - using a 'select do' set of conditions to find where the Quantity entered equals one of the conditions (values now stored in variables PBQty1, PBQty2, PBQty3). When a match is found , I set the 'Price' field to either PBVal1, PBVal2, PBVal3 as necessary. well, that's the theory!

 

[trigger for ‘Quantity’ field]

let InputCode := Code;

let PBQty1 := first((select Table1)[ItemCode = InputCode].FirstQty);

let PBVal1 := first((select Table1)[ItemCode = InputCode].FirstValue);

let PBQty2 := first((select Table1)[ItemCode = InputCode].SecondQty);

let PBVal2 := first((select Table1)[ItemCode = InputCode].SecondValue);

let PBQty3 := first((select Table1)[ItemCode = InputCode].ThirdQty);

let PBVal3 := first((select Table1)[ItemCode = InputCode].ThirdValue);

switch Quantity do

case Quantity = PBQty1:

Price := PBVal1

case Quantity = PBQty2:

Price := PBVal2

case Quantity = PBQty3:

Price := PBVal3

end

unfortunately the 'price' field is not being set with a value from the above....something silly I've missed?

1 reply

null
    • Mel_Charles
    • 4 yrs ago
    • Reported - view

    Hi all. don't worry, I think I've solved the issue now!

    in the switch do case lines, i.e. I have " case Quantity = PBQty1:" . I've owrked out that all I need is "case PBQty1:". 

    Thanks anyway!

Content aside

  • 4 yrs agoLast active
  • 1Replies
  • 685Views