This topic is locked
[SOLVED]

 Check if a dropdown value has been changed

10/2/2011 3:38:52 PM
ASPRunnerPro General questions
Y
yairilan author

Hi,

I have a Dropdown field: values("Appliers")

  1. How can I check on Add or Edit page if it has been changed by the user ( not changed at all, changed to a new value )?
  2. What is the right way use the syntax "If values("Appliers")=null then..." ?
    Thanks

    Yair

Sergey Kornilov admin 10/3/2011

In BeforeEdit event you can use values and oldvalues arrays i.e.

if values("Appliers")<>oldvalues("Appliers") then ...


In BeforeAdd event you can compare the value of field with empty string:

if values("Appliers")<>"" then ...
Y
yairilan author 10/4/2011

Thanks!

I've tried this code:

if values("Appliers")<>oldvalues("Appliers") then ...


BUT, it works well only if the user choose some value in the dropdown box.

If the value is still empty ( Please choose.. ) or if the value in the table is still null, it doesn't work...

Just to let you know if it means something, the value in the lookup is an Integer.
Thanks

Yair

Sergey Kornilov admin 10/4/2011

Yair,
please take a look at the second part of my original reply - it explains how to deal with empty values.

Y
yairilan author 10/4/2011

Thanks!

So according to your answer, do I need to make 2 "if"s: one for the empty option, and one for the different value?

And one more question - in this second answer you wrote it's for "BeforeAdd", can I use it in "beforeEdit" as well? And it's an integer what I have, not a string...

Thanks a lot

Yair

Sergey Kornilov admin 10/4/2011

The number of ifs depends on your business logic. Each if tests it's own condition i.e. if old value is different from new value or if new value is empty.