DBCOMBO question
DBCOMBO question
I´ve been using DBCOMBO to include new records and now I´d like to re-use same resource and same code to edit. The problem is when I load the data from the table to fill my GETs the proper item of the dbcombo is not shown and worse if I exit the dialog with saving option without selecting any option from the DBCOMBOs their datas are lost. Is there a workaround to this?
TIA
TIA
Regards,
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
- Antonio Linares
- Site Admin
- Posts: 42833
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 157 times
- Been thanked: 121 times
- Contact:
Re: DBCOMBO question
There are 3 DBCOMBO (TIPO DE PONTO, ÁREA, FATURAMENTO)
For testing purpose I changed the ÁREA COMBO from dropbox to droplist but result is the same
New record:

Fill data and save:

Edit:

TIPO FATURAMENTO shows 03 but I´d like it to show FARMACIA, same for FATURAMENTO. ÁREA shows nothing (droplist).
I´m not loosing data anymore if I don't click the combos when editing. It was my fault because I forced showing the items for the combos. See comented out in source code.
If nobody reported earlier it might be related to recent changes in COMBOBOX class or I´m missing something.
For testing purpose I changed the ÁREA COMBO from dropbox to droplist but result is the same
New record:

Fill data and save:

Edit:

TIPO FATURAMENTO shows 03 but I´d like it to show FARMACIA, same for FATURAMENTO. ÁREA shows nothing (droplist).
I´m not loosing data anymore if I don't click the combos when editing. It was my fault because I forced showing the items for the combos. See comented out in source code.
Code: Select all | Expand
......
aVars[ 5 ] := pdvs->CODT //ExtNomeTipPdv( pdvs->CODT )
aVars[ 6 ] := pdvs->NCIC
aVars[ 7 ] := pdvs->IEST
aVars[ 8 ] := pdvs->CODA //ExtNomeArea( pdvs->CODA )
.....
aVars[ 21 ] := pdvs->DINI
aVars[ 22 ] := pdvs->TIPF
aVars[ 23 ] := pdvs->COMI
===========================================================================
REDEFINE GET aGets[ 1 ] VAR aVars[ 1 ] ID 101 OF oFld:aDialogs[ 1 ]
REDEFINE GET aGets[ 2 ] VAR aVars[ 2 ] ID 102 OF oFld:aDialogs[ 1 ] PICTURE "@!"
REDEFINE GET aGets[ 3 ] VAR aVars[ 3 ] ID 103 OF oFld:aDialogs[ 1 ] VALID if( ChkVaz( aVars[ 3 ] ), ( aButt[ 1 ]:Enable(), .T. ), ( aButt[ 1 ]:Disable(), .F. ) ) PICTURE "@!"
REDEFINE GET aGets[ 4 ] VAR aVars[ 4 ] ID 104 OF oFld:aDialogs[ 1 ] PICTURE "@!"
REDEFINE DBCOMBO aGets[ 5 ] VAR aVars[ 5 ] ALIAS "TIPP" ITEMFIELD "CODT" LISTFIELD "NOME" ID 105 OF oFld:aDialogs[ 1 ] UPDATE
REDEFINE GET aGets[ 6 ] VAR aVars[ 6 ] ID 106 OF oFld:aDialogs[ 1 ] VALID ChkNCic( aVars[ 6 ], aGets[ 6 ] )
REDEFINE GET aGets[ 7 ] VAR aVars[ 7 ] ID 107 OF oFld:aDialogs[ 1 ]
REDEFINE DBCOMBO aGets[ 8 ] VAR aVars[ 8 ] ID 108 OF oFld:aDialogs[ 1 ] ALIAS "AREA" ITEMFIELD "CODA" LISTFIELD "NOME" ON CHANGE SetScopeRota( aVars[ 8 ], aGets[ 54 ] )
REDEFINE GET aGets[ 9 ] VAR aVars[ 9 ] ID 109 OF oFld:aDialogs[ 1 ] PICTURE "@!"
........
REDEFINE DTPICKER aGets[ 21 ] VAR aVars[ 21 ] ID 121 OF oFld:aDialogs[ 1 ]
REDEFINE DBCOMBO aGets[ 22 ] VAR aVars[ 22 ] ID 122 OF oFld:aDialogs[ 1 ] ALIAS "TIPF" ITEMFIELD "CODF" LISTFIELD "NOME"
REDEFINE GET aGets[ 23 ] VAR aVars[ 23 ] ID 123 OF oFld:aDialogs[ 1 ] PICTURE "99"
If nobody reported earlier it might be related to recent changes in COMBOBOX class or I´m missing something.
Regards,
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
- Antonio Linares
- Site Admin
- Posts: 42833
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 157 times
- Been thanked: 121 times
- Contact:
Re: DBCOMBO question
André,
Thanks for the screenshots.
I have just tested FWH samples/Testdbc1.prg and seems to behave fine. Would you mind to build it and check if it fails too ?
buildh.bat testdbc1
Thanks for the screenshots.
I have just tested FWH samples/Testdbc1.prg and seems to behave fine. Would you mind to build it and check if it fails too ?
buildh.bat testdbc1
Re: DBCOMBO question
In testdbc1 you are not retrieving/editing any data. The problem is that when I retreive data the actual code is shown and not the meaning of the code which I think is the purpose of DBCOMBO.
Selecting FARMACIA saves 03 which is correct, but loading 03 shows 03 and I think it should show FARMACIA.
Selecting FARMACIA saves 03 which is correct, but loading 03 shows 03 and I think it should show FARMACIA.
Regards,
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
- Antonio Linares
- Site Admin
- Posts: 42833
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 157 times
- Been thanked: 121 times
- Contact:
Re: DBCOMBO question
André,
If you add this method to Class TDbCombo:
then this modified testdcb.prg wors fine (selected items are preselected):
If you add this method to Class TDbCombo:
Code: Select all | Expand
METHOD Set( cItem ) CLASS TDBCombo
local nAt := AScan( ::aItems, { | c | Upper( c ) == Upper( cItem ) } )
if nAt != 0
::Select( nAt )
else
SetWindowText( ::hWnd, cItem )
endif
return nil
then this modified testdcb.prg wors fine (selected items are preselected):
Code: Select all | Expand
/*
Program : DBC1.PRG
Purpose : Test DBCombo
Notes :
*/
#include "fivewin.ch"
#include "dbcombo.ch"
function main()
local oDlg, oDBC1, oDBC2, cVar, oCust, cStateID:="CA", oBtn, cState:=" "
local cDept:= "200", oStates, aItems, aList
field NAME
if file("states.dbf")
use states
index on upper(NAME) to temp
database oStates
else
msgInfo("File states.dbf not found.")
endif
define dialog oDlg
@ 10,30 dbcombo oDBC1 var cStateID of oDlg;
alias oStates:cAlias;
size 100,200 pixel;
itemfield "CODE" ;
listfield "NAME";
update;
aList:= {"Accounting","HR","Marketing","Production","Research","Shipping","Sales"}
aItems:= {"100","200","400","300","600","500","700"}
@ 30,30 DBCOMBO oDBC2 VAR cDept;
items aItems;
size 100,200 pixel;
list aList;
of oDlg;
update
@ 50, 50 button oBtn prompt "Selected";
of oDlg pixel ;
action msgInfo( "cStateId: " +cStateID +CRLF+"DeptNo: "+cDept,"Selected" );
default
activate dialog oDlg center;
ferase("temp.ntx")
return nil
// EOF
- Antonio Linares
- Site Admin
- Posts: 42833
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 157 times
- Been thanked: 121 times
- Contact:
Re: DBCOMBO question
Tested and everything seems OK now. Thanks a lot.
Regards,
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
Re: DBCOMBO question
Hi Antonio,
I have just download and tested the 13.05.
It gives the an error like below.
I have realized the new Set method. I have changed it and now my app. works now without error.
Can you please confirm it?
I have just download and tested the 13.05.
It gives the an error like below.
Code: Select all | Expand
Application
===========
Path and name: D:\PRG\CRM\Crm.exe (32 bits)
Size: 3,834,368 bytes
Compiler version: xHarbour build 1.2.2 Intl. (SimpLex) (Rev. 9719)
FiveWin Version: FWHX 13.05
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 6 mins 12 secs
Error occurred at: 12/06/2013, 22:00:12
Error description: Error BASE/1102 Argument error: UPPER
Args:
[ 1] = N 2
Stack Calls
===========
Called from: => UPPER( 0 )
Called from: .\source\classes\DBCOMBO.PRG => (b)TDBCOMBO:SET( 458 )
Called from: => ASCAN( 0 )
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:SET( 458 )
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:DEFAULT( 244 )
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:INITIATE( 276 )
Called from: => __OBJSENDMSG( 0 )
Called from: => HB_EXECFROMARRAY( 0 )
Called from: .\source\function\HARBOUR.PRG => OSEND( 287 )
I have realized the new Set method. I have changed it and now my app. works now without error.
Can you please confirm it?
Code: Select all | Expand
METHOD Set( cItem ) CLASS TDBCombo
local nAt
if ValType(cItem) = "C"
nAt := AScan( ::aItems, { | c | Upper( c ) == Upper( cItem ) } )
ELSE
nAt := AScan( ::aItems, { | c | c == cItem } )
ENDIF
if nAt != 0
::Select( nAt )
else
SetWindowText( ::hWnd, cItem )
endif
return nil
Regards,
Hakan ONEMLI
Harbour & MSVC 2022 & FWH 23.04
Hakan ONEMLI
Harbour & MSVC 2022 & FWH 23.04
- Antonio Linares
- Site Admin
- Posts: 42833
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 157 times
- Been thanked: 121 times
- Contact:
Re: DBCOMBO question
Hakan,
Your fix is fine, thanks
I missed non-string values, my mistake, sorry. We were so focused on strings that paid no attention to other types
Your fix is fine, thanks

I missed non-string values, my mistake, sorry. We were so focused on strings that paid no attention to other types