DbCombo Problem

Post Reply
Milan Mehta
Posts: 115
Joined: Mon Oct 17, 2005 4:42 am
Location: India

DbCombo Problem

Post by Milan Mehta »

Dear All,

I am using May-2006 build. I face two problem while using a Numeric Item Field.

1) I have to initialise the variable with Record Position + 1, instead of actual value. This is not the case with Character value.
2) In above case, variable is initialised with above Record Position. If Dbcombo, do not get the focus, its value remains record position only.
3) While issuing oDbc:Refill(), I get error on DbCombo.PRG => TDBCOMBO:RILL(167). It seems typo, Rill instead of Fill.

Can anybody shed light on it ?

Below is the sample code.

TIA
Milan.

---------------------------Cut-------------------------------------
# include "fivewin.ch"
# include "DBCOMBO.CH"

function Main()

local oDlg, oCbx, obtn, nItemCode
local cName := ' '

Cret_Test()

DEFINE DIALOG oDlg FROM 10, 10 TO 20, 50 ;
TITLE "DBomboBox Test"

nItemCode := 3

SELECT Test
Locate for Itemcode==nItemCode
IF found()
nItemCode := RecNo() + 1
ELSE
nItemCode := 0
endif

@ 0.5, 1 GET cName PICTURE "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

@ 1.5, 1 DBCOMBO oCbx VAR nItemCode ALIAS "TEST" ITEMFIELD "ITEMCODE" LISTFIELD "ITEMNAME"

@ 2, 1 SAY nItemCode PICT '999'

@ 3, 1 BUTTON obtn ACTION New_Rec(oCbx)

ACTIVATE DIALOG oDlg CENTERED

MsgInfo (nItemCode)

RETURN NIL

PROCEDURE Cret_Test
LOCAL aTest := {;
{ "ITEMCODE" , "N", 5, 0 },;
{ "ITEMNAME" , "C", 30, 0 } }
DBCREATE ('TEST', aTest)

SELE 0
USE TEST
FOR I = 1 TO 10
APPE BLANK
REPLACE ITEMCODE WITH 11-I
REPLACE ITEMNAME WITH 'ITEM-'+STR(11-I,5)
NEXT
RETURN

PROCEDURE add_rec()
LOCAL nRec

SELECT Test
appe blank
nRec := LASTREC() + 1

REPLACE ITEMCODE WITH nRec
REPLACE ITEMNAME WITH 'ITEM-' + LTRIM (Str(nRec,5))

COMMIT
RETURN

PROCEDURE New_Rec(oCbx)
add_rec()
oCbx:Refill()
oCbx:ReSet()
oCbx:DEFAULT()
return
---------------------------Paste----------------------------------
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Milan,

The rill() typo was fixed in the next release.

DBCombo is a subclass of the Combobox class and the Combobox class was designed to use character data only. I received a number of requests to allow the use of numeric data for the itemfield value so I attempted to provide this capability, but the more I worked on it the more complicated it became. The problem is that the Combobox class allows the use of numeric values in some of its methods but it assumes that if they are numeric they are record numbers, not data. This may be fixable, but it is going to require a lot of work and I don't know when I will be able to look at it.

I have never used a numeric value for a code (itemno, custno, etc) so it has never been a problem for me. If you are developing a new application, I suggest simply not using numeric values for codes. If you have a legacy application, then I suggest using arrays and the dbcombo:setItems( aItems, aList ) method. File the aItems array with cValToChar( itemcode). And if you wish to use the incremental search then don't forget to index the database on upper(itemname) before loading the arrays.

James
Post Reply