Page 1 of 1

Workaround to make DBCOMBO to work with numeric Item field

Posted: Wed Feb 22, 2006 6:57 am
by Milan Mehta
Hello,

Is there any workaround to make DBCOMBO to work with numeric Item field ? We are in the process of converting legacy application into FWH. And almost all the applications has numeric primary key in the master table. I am heavily stuck up here.

Can anybody guide me ?

TIA
Milan.

Re: Workaround to make DBCOMBO to work with numeric Item fie

Posted: Wed Feb 22, 2006 7:41 am
by Enrico Maria Giordano
Can't you just use Str( FieldName )?

EMG

Posted: Wed Feb 22, 2006 7:45 am
by James Bott
Milan,

You can preload the data into arrays (and convert the data to string while doing that). Then use the SET method:

METHOD SetItems( aItems, aList )

When you save the selected item no. you may need to convert it back to numeric.

The problem is that the data needs to be string for the combobox class which is the base class of dbcombo.

Another way would be to modify the dbcombo source. The downside is that you will either not automatically get any improvements to newer versions of DBCombo that come with FW.

Maybe the best thing would be to customize a copy of dbcombo and give it a new class name. That is probably what I would do, but if you are not familiar with writing classes this may take some effort for you.

James

Posted: Thu Feb 23, 2006 11:00 am
by Milan Mehta
Dear James,

Do u mean to say that I should try to array browse with DBCOMBO ? Even that do not seem to work as the value return by DBCOMBO is still numeric (i.e. still from Database). I had filled both aItems and aList with proper values (string one).

Can u please guide further ?

TIA
Milan.


James Bott wrote:Milan,

You can preload the data into arrays (and convert the data to string while doing that). Then use the SET method:

METHOD SetItems( aItems, aList )

When you save the selected item no. you may need to convert it back to numeric.

The problem is that the data needs to be string for the combobox class which is the base class of dbcombo.

Another way would be to modify the dbcombo source. The downside is that you will either not automatically get any improvements to newer versions of DBCombo that come with FW.

Maybe the best thing would be to customize a copy of dbcombo and give it a new class name. That is probably what I would do, but if you are not familiar with writing classes this may take some effort for you.

James

Posted: Thu Feb 23, 2006 2:19 pm
by James Bott
Milan,

Even that do not seem to work as the value return by DBCOMBO is still numeric (i.e. still from Database). I had filled both aItems and aList with proper values (string one).


I see there is a bug in DBCombo when you try to pass the arrays in the definition like this:

@ 10,30 dbcombo oDBC var cItem of oDlg;
items aItems;
list aList

Instead do it like this:

@ 10,30 dbcombo oDBC var cItem of oDlg
oDBC:setItems( aItems, aList )

This is working for me.

James