Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SQL fed drop down, two label values

cyan_studios
Level 2
Level 2
Hello all.

I have a drop down menu that's fed by an SQL database for a timecard. This database has three records for an employee, the first name, last name, and employee ID.



I need the drop down to give me both "fname", "lname", and the actual value needs to be "empl". first name, last name, and employee ID, respectively.



Is there some syntax that can be entered into the binding dialog that will call both "fname" and "lname" to show a full name. These employees are not going to be keen on selecting a first name, then a last name. Plus, if two people have the same last name, we could have conflicting employee ID's from first to last names.



It's a mess.



Any help's appreciated, thank you.
4 Replies
pguerett
Level 10
Level 10
The dropdown ony supports a single column ...it is not a multiple column display.
Not applicable
Hi,

You could append values from different data columns with the following loop, for example.



while(j<20000)

{



ssText = oTextNode.value;

ssValue = oValueNode.value;

ssText += " / " + ssValue;

this.addItem(ssText);

oDB.next();

j++;

}

your drop down would then be able to show last and first name or more.



Steve
cyan_studios
Level 2
Level 2
Steve, I'm very interested in using that technique. So for some clarification, where would I put this script? On a calculate or initialize event in the drop down?



And I assume there are values in your script that I have to replace. Like oTextNode to the text field name in the database, etc.?



In that case, there's a binding that I need to set on this drop down too then, before the script, yes?
Not applicable
Hi,



You could put it in the Initialize event for the drop down.

Look at the script for the custom drop down list in the initialize event. Find the following while statement,



while(!oDB.isEOF())

{

this.addItem(oTextNode.value, oValueNode.value);

oDB.next();

}



Instead of adding just the oTextNode value to the drop down list you can use this string append to display more info from different columns

of your database.



ssText += " / " + ssValue;

this.addItem(ssText);



For example, the "/" could be replaced with a "," and ssText could be

the Last Name and ssValue could be the First Name.



You would then be displaying "Last Name, First Name" in your drop down list.



Steve