Is it possible say, from showing a list of names in a combo , each of which have id numbers in another field or element in an array , to easily include the id in a variable after selection of a name in the combo.
Yes,
Use a multi-dimensional array, with each element being a seperate column. So if you have the following infromatin:
Bob Smith 12134
Mary Jane 12135
Tim Thomas 13333
As an array, there are 3x3 elemnts. this.array(1,1) = Bob
with an array the first number represnets your row, while the second represent the column. So your data source has to reference the array properly. (2,1), (1,1) or (3,1) if you want the last name in your combo box.
THEN, once you've selected them, simply pluck the other array element out of the row. If you select "Jane" you now know you have array row 2, column 2 and you then want row 2, column 3 for the ID.
Simply assign it on your ClickEvent:
oMyObject.Value = This.Array(ListItem,3)
will assign the value of the 3rd array element from row 2 (based on the ListItem which will be equal to the number of the item you just selected, and therefore equal to the row number).
You'll need to play with the Combo Box control some to get the full grasp. If you've not dealt with array's before, they are just like dealing with a table in memory, where you reference them by row and column number. (Like Excel).
Best Regards,
Scott
"Everything should be made as simple as possible, and no simpler."
Simply assign it on your ClickEvent:
oMyObject.Value = This.Array(ListItem,3)
My combo is called cboNames
My array is called aMyNameList and the builder has placed this in RowSource
NumberOf Elements =ALEN(aMyNameList)
ColumnCount =ALEN(aMyNameList,2)
- I can't find a way to work these in ( substitute) in your statement.
I can obviously use [name1 = this.value] where I get the assigned element value in my case [1,1]
First, you don't need to set NumberOfElements; that's a backward compatibility item.
Set BoundTo to .T., so that the combo can work with numeric values. Set BoundColumn to 3, and you won't need any code to have the value of the combo be the id of the selected item.
Then, in any code where you need the id, you can just cboName.Value.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.