Is it true that ONLY character type data can be used in arrays along with DBCombo . Or is there any other way of using it. I have found that if numeric data is used in aItems in DbCombo, then DbCombo returns the Array index number instead of the actual Value from the aItems
Can anybody confirm it
For eg:
LIST arrays has to contain only Character type data in it
ITEMS arrays has to contain only Character type data in it
- Code: Select all Expand view
- #include "FiveWin.ch"
#include "DbCombo.ch"
//-----------------------------------------------//
FUNCTION Main()
//-----------------------------------------------//
Local oDlg, oDbCmb1,oDbCmb2,oSay1,oSay2
Local aList1,aItem1,aList2,aItem2,nVar1,nVar2,cSay1,cSay2
aList1:={"MCA","BCA","DDC","ENG"}
aItem1:={"101","102","103","104"} // Has to be Character type data
/* If the Values in aItem1 is Numeric like the following
aList1:={"MCA","BCA","DDC","ENG"}
aItem1:={101,102,103,104} // Numeric data
then the returning values will be 1,2 3 (Array elemt no instead of the values 101,102,103,104)
*/
aList2:={}
aItem2:={}
nVar1:="101" ; nVar2:=spac(3) // DbCombo VAR has to be a Character type
DEFINE DIALOG oDlg TITLE "Test" FROM 0,0 to 20,50
@1,1 SAY oSay1 VAR " " OF oDlg UpDate
@2,1 SAY oSay2 VAR " " OF oDlg UpDate
@4,1 DBCOMBO oDbCmb1 VAR nVar1 OF oDlg UPDATE ;
ITEMS aItem1 ;
LIST aList1 ;
SIZE 120,200 ;
ON CHANGE ( SetItems(nVar1,@nVar2,oDbCmb2), ;
oSay1:SetText(nVar1),oSay2:SetText(nVar2) )
@5,1 DBCOMBO oDbCmb2 VAR nVar2 OF oDlg UPDATE ;
ITEMS aItem2 ;
LIST aList2 ;
SIZE 120,200 ;
ON CHANGE oSay2:SetText(nVar2)
ACTIVATE DIALOG oDlg
Return NIL
//-----------------------------------------------//
Function SetItems2(nVar1,nVar2,oDbCmb2)
//-----------------------------------------------//
Local aList2,aItem2
*MsgInfo(nVar1) // If numeric type then nVar1 will be 1,2 or 3 (Array elemt no) instead of 102,102,103
if nVar1 == "101"
aList2:={"M1","M2","M3"}
aItem2:={"201","202","203"}
elseif nVar1 == "102"
aList2:={"B1","B2","B3"}
aItem2:={"301","302","303"}
elseif nVar1 == "103"
aList2:={"D1","D2","D3"}
aItem2:={"401","402","403"}
elseif nVar1 == "104"
aList2:={"E1","E2","E3"}
aItem2:={"501","502","503"}
Endif
oDbCmb2:SetItems(aItem2,aList2)
nVar2:=aItem2[1]
Return NIL
I have made a very serious mistake in my code assuming that Numeric data type array works fine with DbCombo. But my PRG worked perfectly. Only recently I came to know about this. Fortunately or unfortunately the Data inside the ITEMS array was numeric 1,2,3,4,5,6 series, so my program worked perfectly as DbCombo returned array index value 1,2,3,4,5,6 because the aItems data was numeric
Is it like this DbCombo is expected to work, or is there anything else I have to take care. Would have been nice if DbCombo could handle numeric aItems data too.
Regards
Anser