Hi,
I am trying to figure out if my approach of setting ControlSource of a combobox is wrong.
Here is the situation.
A combobox control has ControlSource set to a field in a cursor (e.g. C_MYTABLE.SITE_NO)
The combobox uses RowSource type array and the RowSource is set to an array property of the combo (e.g. aLookup). The array has two columns, the first column stores a number value and the second column is description. E.g:
aLookup[1,1]=0
aLookup[1,2]="Name of Site A"
aLookup[2,1]=1
aLookup[2,2]="Another Site B"
The array aLookup is populated in the INIT method of the combobox.
What happens is the value in the field C_MYTABLE.SITE_NO get the value of the top/first value of the first column of the array aLookup. For example, if ALL values of C_MYTABLE.SITE_NO are 0 (zero) (when the cursor is created), as soon as the array aLookup is populated (in the INIT method of the combo), the value of C_MYTABLE.SITE_NO becomes 1. This is because the top element of the aLookup (which is sorted on the second column) is 1. I thought that the value of the field C_MYTABLE.SITE_NO should "control" the selection in the combobox, not the other way around.
What am I missing? TIA.
UPDATE. I seem to have solved the problem by commenting the following line in the INIT method of the combobox:
this.ListIndex = 1
The above command was right after the array aLookup was populated and the combo RowSource was set to this array.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham