Select a default value of a Combo box in Centura/Gupta (Team Developert)

63 Views Asked by At

I am trying to configure a combo box so that it shows a default value and does not show empty.

The structure is as follows:

`ccmbDynamic: cmbcombo
-List Initialization
*Message Action
 *On PAM_Create
 -Set nMyObjectID = 1
 -Call clsDynamicListPopulateFull('Table_name', 'code_id', 'Description', 'Condition Where', 
                                  'code_id', 1, CMD_Description, DT_Number, CMD_ForceFetch)
 -Call SalsendMsg(cmbcombo, SAM_Click, 0, 0)

 *On PAM_SAM_Click
 -Call IntSqlInmediately ('SELECT code_id FROM Table_name WHERE Condition')`

Does anyone know what process I am doing incorrectly? The queries return the correct information, but the selection is not reflected in the combo (The selected default), only when I click is that the information is seen, I need it to be seen before the click, some help on this?

1

There are 1 best solutions below

3
On

Its not clear what is happening at class level ( ccmbDynamic ) as you don't show it.

In fact it's not clear what any of this code is doing.

But a much easier way to Populate a combo is to use SalListPopulate ( hWndCombo, hSql, 'Your select Statement' ), and this will fetch from the dB and fill the combo at the same time. If you then want to select a specific entry in the combo, call SalListSetSelect ( hWndCombo, nIndexToSelect ) e.g. SalListSetSelect ( hWndCombo, 0 ) to select the first entry. e.g.

On SAM_Create
  If SalListPopulate( hWndCombo, hSql, 'SELECT code_id FROM Table WHERE 
                                       Condition' )
     ! Set list box selection to the first item.
     ! If you specify -1, SQLWindows deselects the selected entry
     Call SalListSetSelect( hWndCombo, 0 ) 

                                                                                                                                                           

p.s. Unrelated to the question, but worth mentioning.... I do hope your user function IntSqlInmediately does not actually call the builtin function SqlImmediate() ( you'd best check this out ) - as this was depricated many years ago by Gupta in favour of SqlPrepareAndExecute(hSql, 'Your select Statement') followed by SqlFetchNext(hSql, nFetched). The reason SqlImmediate() was depricated, was that programmers were too lazy to release the internal handle connected by the function, by then calling SqlClearImmediate (). So if you insist on using SqlImmediate() - remember to follow with SqlClearImmediate() . Otherwise those internal handles will buildup ad-infinitum until you get a GPF.