Expand my Community achievements bar.

Creating Variable for Data Connection Name

Avatar

Level 10
Sorry to be coming back so quickly with "cap in hand".



Having sorted out the Form to transfer data into Access, I am trying to set up a second Form which will be populated based on the Users choice of "Red List, "Amber List" or "Green List" (grouped Radio Buttons).



I have being trying to set up a variable script to set a name for the appropriate data connection based on which button the User has selected. To test this I have a temporary Text field displaying the variable (DBList.sHazardColour).



The variable script looks like this:



if (form1.#subform[0].ListType == Null)

{

var sHazardColour = "Null";

}

else

{

var sHazardColour = "";

}

if (form1.#subform[0].ListType == 1)

{

var sHazardColour = "Red_List";

}

else

{

var sHazardColour = "";

}

if (form1.#subform[0].ListType == 2)

{

var sHazardColour = "Amber_List";

}

else

{

var sHazardColour = "";

}

if (form1.#subform[0].ListType == 3)

{

var sHazardColour = "Green_List";

}

else

{

var sHazardColour = "";

}



The Access Database is setup with three different tables, one for each coloured list.



My approach is that if I can get the variable script to work, then I can apply this variable in the "$sourceSet.DataConnection." commands by replacing DataConnection" with "DBList.sHazardColour".



From the above, can you see where I am going wrong.



Thanks,



Niall
2 Replies

Avatar

Former Community Member
From a quick glance I see you have 3 seperate if/else statements. This means that all 3 will be evaluated seperately and in the end shazardColour will either by "Green_List" or "". No other value is possible. What you want is nested if/else statements, so something like this:



if (nullCheck) {

...

} else if (redCheck) {

...

} else if (amberCheck) {

...

} else if (greenCheck) {

...

} else {

...

}



Chris

Adobe Enterprise Developer Support

Avatar

Level 10
Thanks Chris,



I will bear this in mind for the future. I have given up on that approach and trting to keep it simplier.



From the number of postings it feels like I am seeing RED.



Hopefully we will get there in the end.



Thanks,



Niall