main logo
Subject: combobox requery()
Author: graeme thomson
Posted: 2001/05/08 13:48:45
 
View Entire Thread
New Search


Can someone help explain some unexpected behaviour with combobox requery()?

I have a combobox table with the names (LUName ) and List_Type containing a 2 character code. e.g. Colours are CO, Breeds BR and so on.

I have a generic combobox based on cifcombobox with a property cComboCode to hold a reference to the List_Type.

GetSQLStatement() has the following code, the purpose of which is to produce a generic combobox which requires only 2 properties be filled in when it is used - cifAlias and cComboCode:

THIS.ROWSOURCE = "SELECT LUName, cID FROM Combos ;
WHERE Active = .T. AND List_Type = THIS.cComboCode ;
ORDER BY LUName INTO CURSOR " + THIS.cifAlias

llRetVal = NOT EMPTY( THIS.ROWSOURCE )

IF llRetVal
THIS.cLookupAlias = THIS.cifAlias
ENDIF

RETURN llRetVal

This works fine and populates the combobox correctly and it functions as expected.

HOWEVER:
If I Requery() the combobox I get the error: Property cComboCode not found!

The only way I can solve this behaviour is by changing GetSQLStatement() to:

LOCAL cComboCode

cComboCode = THIS.cComboCode

THIS.ROWSOURCE = "SELECT LUName, cID FROM Combos ;
WHERE Active = .T. AND List_Type = [&cComboCode] ;
ORDER BY LUName INTO CURSOR " + THIS.cifAlias

llRetVal = NOT EMPTY( THIS.ROWSOURCE )

IF llRetVal
THIS.cLookupAlias = THIS.cifAlias
ENDIF
RETURN llRetVal

i.e. macrosubstituting THIS.cComboCode with &cComboCode

then in the Requery()

LOCAL lcAlias, lcTag

lcAlias = THIS.cifAlias
lcTag = THIS.cTag

DODEFAULT()

THIS.lTagExists = IsTag( lcTag, lcAlias )

THIS.lTagExists returns FALSE when prior to the Requery() it returned TRUE. I have even tried recreating the index after the DODEFAULT(). If I do that THIS.lTagExists returns TRUE but the seek in LookupValue() produces error: Tag not found!
The same error also occurs if THIS.lTagExists is not reset (because it stays TRUE!!)

So I can solve the problem but I have no idea why it occurs.
Any suggestions?




 
©2001 graeme thomson
<-- Prior Message New Search Next Message -->