Expand my Community achievements bar.

SOLVED

Populating a field based on the value on a different page

Avatar

Level 4

Hi All,

I do have a form I am working on, and I have all other scripts I have written on it working except one. There is a Calculate field that based on it's value, it checks the check box on page one depending on the range. This Calculated is readOnly. I wrote the following code, and put on the Exit event, but it is not working. Please can someone help me out with why it is not workiong.

if((form1.Page5.raterec1.rawValue>=1)&&(form1.Page5.raterec1.rawValue<2)){

     rrun1.rawValue==1;

}

if((form1.Page5.raterec1.rawValue>=2)&&(form1.Page5.raterec1.rawValue<5)){

        rrsuccess1.rawValue==1;

}

if((form1.Page5.raterec1.rawValue>=5)&&(form1.Page5.raterec1.rawValue<=6)){

     rrout1.rawValue==1;

}

Thanks

v/r

LucPian

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I think that we are getting closer:

User selects dropdown > this sets value of raterec > script in dropdown looks at value of raterec and then sets values of checkboxes.

I think what is happening is that the script sets the value of raterec okay. BUT continues with the checkbox script BEFORE raterec's rawValue is set with the new value.

So I would split the script.

Have script in the checkbox's calculate event that looks at the rawValue of raterec (see previous post). When the rawValue of raterec changes, the script in the checkboxes will automatically fire.

Then the script in the dropdown just changes the rawValue of raterec.

Checkbox script looks at >>>>>>>>> raterec.rawValue

                                                                      ^

                                                                      ^

                                       dropdown script sets ^

(rubbish diagram)

Niall

Assure Dynamics

View solution in original post

8 Replies

Avatar

Level 10

Hi,

You use a double equal sign when testing equality:

if (this.rawValue == 1)

{

     // script in here

}

However when setting a value you just use a single equal sign:

rrun1.rawValue = 1;

Hope that helps,

Niall

Assure Dynamics

Avatar

Level 4

Hi Nial,

Thanks, but it is not working, and I guess knowing which is the right event to place it on, because, it briefly works the next time you go back to the field and exit from it. So, it looks like it hangs somewhere.

Thanks

v/r

Lucpian

Avatar

Level 10

Hi Lucpian,

Which objects are you putting the script into:

raterec?

If so are the rrun1, rrsuccess1 and rrout1 on the same page? Or are they on another page?

If you let me know I think we can tighten the script. I just need to know where things are.

Niall

Assure Dynamics

Avatar

Level 4

Hi Nial,

No, raterec is on the fifth page of the form, while rrun1 is on the first page. raterec is a ReadOnly field.

Thanks

v/r

Lucpian

Avatar

Level 10

Hi Lucpian,

As raterec is readOnly, there isn't much point in scripting there.

I would split the script, one for each checkbox. Please this in the calculate event of the rrun1 checkbox:

if (Page5.raterec1.rawValue >= 1 && Page5.raterec1.rawValue < 2)

{

     this.rawValue = 1;

}

else

{

     this.rawValue = 0;

}

Then similar for rrsuccess1 and rrout1 checkboxes.

You need to make sure that the raterec object on Page5 is not inside other subforms. If so you will need to include these in the reference. Also make sure that you do not have un-named objects, subforms or pages and that there are not multiple objects with the same name.

Niall

Assure Dynamics

Avatar

Level 4

Hi Nial,

I have this code on a drop down list which values equates raterec, and depending on what the value of raterec, any of the checkboxes could be checked. It is working, but works on the second clicking in the dropdownlist which is not how it should work. I have this code on the Exit event of the dropdown list.

Thanks

v/r

Lucky

Avatar

Correct answer by
Level 10

Hi,

I think that we are getting closer:

User selects dropdown > this sets value of raterec > script in dropdown looks at value of raterec and then sets values of checkboxes.

I think what is happening is that the script sets the value of raterec okay. BUT continues with the checkbox script BEFORE raterec's rawValue is set with the new value.

So I would split the script.

Have script in the checkbox's calculate event that looks at the rawValue of raterec (see previous post). When the rawValue of raterec changes, the script in the checkboxes will automatically fire.

Then the script in the dropdown just changes the rawValue of raterec.

Checkbox script looks at >>>>>>>>> raterec.rawValue

                                                                      ^

                                                                      ^

                                       dropdown script sets ^

(rubbish diagram)

Niall

Assure Dynamics

Avatar

Level 4

Thanks Nial, it works now. I just split the scripts between the checkboxes on the calculate events.