>I have a drop-down listbox in Visual Class Form; code
>is shown below. See embedded comments for clarifications.
>
>QUESTION is below code snippets.
>
>I have code in my Visual Class Form init() routine:
>
>form.init()
>...
>...
>SELECT TRIM(DD_ships.sh_name)+" "+TRIM(DD_ships.sh_type)+"-"+TRIM(DD_ships.sh_hno) AS ship, ;
> DD_sdilist.sl_shipid,TRIM(DD_ships.sh_type),val(DD_ships.sh_hno), ;
> DD_sdilist.sl_idxtype ;
> FROM DD!DD_sdilist inner JOIN DD!DD_ships ON ;
> DD_sdilist.sl_shipid=DD_ships.sh_shipid ;
> &l_cWhere ;
> ORDER BY 3,4 INTO CURSOR curSDIlist
>...
>
>*// cboShip is drop-down listbox
>*// RowSourceType is 6 - Fields
>
>THISFORM.cboShip.ROWSOURCE="curSDIlist.ship,sl_shipid"
>...
>...
>
>
>* In cboShip.InteractiveChange() method code is:
>
>WITH THISFORM
>...
>...
>...
> SELECT DISTINCT dd_sdidata.si_index FROM dd_sdidata ;
> WHERE dd_sdidata.si_shipid=VAL(THIS.VALUE) INTO CURSOR
> curIndexList
>...
>...
>ENDWITH
>
>>>>>>>>>>>
>
>My question is how does the InteractiveChange() method for drop-down list pick the 2nd column (Field) from Rowsource for cboShip Value. I've confirmed this fact through debugging.
>
>FZ (Boston MA)
Donald,
Welcome. As Tracy pointed out BoundColumn = 2 provides that.
However when a combo/list has a rowsource of any kind that's an alias (fields,sql,query,alias) record pointer moves in its rowsource cursor/table as you walk within the items. And no matter how many columns of underlying cursor/table you use in conbo/list all columns are actually available to you.
ie:
with myCombo
.RowSourceType = 6
.RowSource = 'customer.Company,cust_id'
.BoundColumn = 2
.ColumnCount = 2
endwith
? myCombo.Value
or :
with myCombo
.List(.ListIndex,2)
endwith
? customer.company, customer.cust_id, customer.contact
This is straight forward as record pointer in customer is moving as you navigate the combo/list. As you see you can get info from fields not included in combo/list too :) ie: With this approach your interactivechange call might be :
SELECT DISTINCT dd_sdidata.si_index FROM dd_sdidata ;
WHERE dd_sdidata.si_shipid = curSDIlist.sl_shipid ;
INTO CURSOR curIndexList
Showing you where that parameter value comes from right in place (and eliminates val() conversion).
Second as I can see you're first selecting into a cursor and then making that cursor RowSource. You could just make the SQL the rowsource itself with Rowsourcetype = 3. It not only prevents errors like 'curSDIlist not found' that might occur unless you workaround (seems you did) but lets you simply call combo.requery() if its parameters change (ie: select ...from ... where shippingID = thisform.txtShipID.Value ...)
Cetin