How to refresh DBCombo box ?

How to refresh DBCombo box ?

Postby Milan Mehta » Tue Feb 21, 2006 9:33 am

Hello,

I am using DbCombo to select a Value from Master. If the entry do not exist in Master, I have one more button to enter a new value in Master. But that value do not show in DbCombo box now. How can I refresh the dbcombo box ?

I hope I am able to convey my problem.

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

Postby Marcelo Via Giglio » Tue Feb 21, 2006 12:09 pm

Hola,

try :Refill() method

regards

Marcelo
Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Postby James Bott » Tue Feb 21, 2006 4:52 pm

Milan,

As Marcelo says, refill() will reread the data from the database. Of course, you have to add the new item to the database first.

It would be faster to use Add( cItem, nAt, cList ), but you would have to know what location (nAt) to put the item so this may be more difficult. If your database is small I would just use refill().

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Milan Mehta » Wed Feb 22, 2006 5:37 am

James Bott wrote:Milan,

As Marcelo says, refill() will reread the data from the database. Of course, you have to add the new item to the database first.

It would be faster to use Add( cItem, nAt, cList ), but you would have to know what location (nAt) to put the item so this may be more difficult. If your database is small I would just use refill().

James


Dear James / Marcelo,

Following is my code snippet, which it still not working (in spite of Refill() use)

Can u guide me further ?

--------------------------------Cut-------------------------
REDEFINE DBCOMBO oPackCode VAR oInv:aItem[nItem, 4] ID CBINVTRPACKTYPE OF oDlgItem UPDATE;
ALIAS 'PACK' ;
ITEMFIELD 'PACKCODE' ;

LISTFIELD 'PACKNAME' ;
VALID !Empty(oInv:aItem[nItem, 4])

REDEFINE BUTTON ID PBINVTRPACKNEW ACTION Ins_Pack (oDlgItem, 'Add'), oPackCode:Refill()

------------------------------------------Paste-----------------------------

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

Postby James Bott » Wed Feb 22, 2006 8:26 am

Milan,

I vaguely remember that you have to call reset() after refill(). Try that and let me know if it works. If so, I will add reset() to the refill() method and suggest that change to Antonio.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Milan Mehta » Wed Feb 22, 2006 9:56 am

Dear James,

No, using Reset() removes all the item in dbcombo. Issuing Refill() again also do not bring them back.

Can u just experiement it ?

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

Postby James Bott » Wed Feb 22, 2006 10:05 am

Milan,

OK, I found an example in an app that I wrote. You have to call refill(), reset(), default(). You can try it or wait and I will try it tomorrow.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Milan Mehta » Wed Feb 22, 2006 1:08 pm

James Bott wrote:Milan,

OK, I found an example in an app that I wrote. You have to call refill(), reset(), default(). You can try it or wait and I will try it tomorrow.

James


Dear James,

Please do that for me as even this attempt too failed. Only the newly added entry is missed out. Just try it for urself first.

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

Postby James Bott » Wed Feb 22, 2006 2:37 pm

Milan,

Refill(), reset(), default() works for me. I am using dbcombo.prg dated 11/3/2003. If you are using a version earlier than that it may not work.

Are you are sure you are adding the record to your database?

If you still can't get it working, can you provide a small self contained example?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Milan Mehta » Thu Feb 23, 2006 10:55 am

Dear James,

Yes it does now. It was my fault.

Thanks a lot,

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

Postby James Bott » Fri Feb 24, 2006 2:37 am

Milan,

I am sending you an email. Please check for it.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Milan Mehta » Fri Feb 24, 2006 7:17 am

James Bott wrote:Milan,

I am sending you an email. Please check for it.

James


Dear James,

The problem of using DBCOMBO on numberic item field still persist. All other problems including incremental search are solved.

For Numeric item field : following is my code snippet :
REDEFINE DBCOMBO oVno VAR nVno ID CBNAME OF oDlg

oVno:SetItems (aItemVno, aListName)

Both aItemVno, aListName are not char array, still the value being returned is Numeric i.e. from Database.

Can you look into the matter ?

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

Postby James Bott » Fri Feb 24, 2006 7:40 am

Milan,

I did not attempt to modify DBCombo to handle numeric data. This will take considerable work and testing. DBCombo is a subclass of Combobox and Combobox cannot handle numeric data, so I'm not sure it can be done without creating a completely new control.

So, the best way for you is to load the two arrays, converting the item data to character when putting it into the array. You will also have to convert your nVno to cVno when going in and from cVno to nVno afterward.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Milan Mehta » Fri Feb 24, 2006 8:00 am

So, the best way for you is to load the two arrays, converting the item data to character when putting it into the array. You will also have to convert your nVno to cVno when going in and from cVno to nVno afterward.

Dear James,

What I am trying to point out is that it does not work as you suggest. I loaded two arrays with character value as follows :
Select Resident
Set ORDER TO TAG Name
GO TOP
DO WHILE !Eof()
AAdd (aListName, NAME)
AAdd (aItemVno, Str(VNO,5))
SKIP
ENDDO

and thereafter issuing following commands :
REDEFINE DBCOMBO oVno VAR cVno ID CBNAME OF oDlg

oVno:SetItems (aItemVno, aListName)

Still the value being returned by cVno is still nueric (i.e. from database) and wrong one also. Am I still missing something ?

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

Postby James Bott » Fri Feb 24, 2006 8:32 am

Milan,

Still the value being returned by cVno is still nueric (i.e. from database) and wrong one also. Am I still missing something ?


OK, now I understand, but it is working for me. I have done some more testing since my last message and I did note that you can pass numerics in aItems and it will return a number, but the number appears to be the location in the array not the value. [This leads me to believe that there may be some hope in using numerics.]

Are you sure you passed characters in the aItems array? If so, can you send me a small, self-contained example showing the problem?

What version of FWH and (x)Harbour are you using?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 60 guests