Thanks for your efforts.
First let me say, when I coded the window - everything works perfectly. It must have something to do with the Resource I'm using. Let me explain what it does:
Click the ComboBox
See 3 choices - Company, Number and Surname
Click on Company
Combobox displays Surname (so does MSGINFO(cTAG)) - database is now in Surname order (although I clicked Company)
Click the ComboBox
See 3 choices - Company, Number and Surname
Click on Number
Combobox displays Company (so does MSGINFO(cTAG)) - database is now in Company order (although I clicked Number)
Click the ComboBox
See 3 choices - Company, Number and Surname
Click on Surname
Combobox displays Number (so does MSGINFO(cTAG)) - database is now in Number order (although I clicked Surname)
There is a pattern, but I can't see what's causing it. f
Here is the code and the resource file, re-done with Borland Resource
Code: Select all
function main()
LOCAL aTAGLIST
LOCAL cTAG:="SURNAME"
LOCAL oDlg_Search, oGet_Searchkey, oBtn
DBCREATE('TEST.DBF',{ ;
{"SURNAME", "C", 30, 0}, ;
{"COMPANY", "C", 30, 0}, ;
{"NUMBER", "C", 7, 0} ;
} )
USE TEST EXCLUSIVE NEW
INDEX ON Upper( TEST->SURNAME ) TAG "SURNAME"
INDEX ON Upper( TEST->COMPANY ) TAG "COMPANY"
INDEX ON TEST->NUMBER TAG "NUMBER"
TEST->(ORDSETFOCUS( cTAG )) //Default order
aTAGLIST:=GETORDNAMES()
DEFINE DIALOG oDlg_Search RESOURCE "SEARCH"
REDEFINE GET oGet_Searchkey ID 10 OF oDlg_Search PICTURE "@!K" UPDATE MESSAGE "ENTER SEARCH"
REDEFINE BUTTON oBtn ID 20 of oDlg_Search ACTION oDlg_Search:End()
REDEFINE DBCOMBO cTAG ID 30 of oDlg_Search items aTAGLIST list aTAGLIST UPDATE ON CHANGE (MSGINFO(cTAG),TEST->(ORDSETFOCUS(cTAG)),oListBox:REFRESH())
REDEFINE LISTBOX oListBox VAR ID 40 OF oDlg_Search FIELDS UPDATE ON DBLCLICK oDlg_Search:End()
ACTIVATE DIALOG oDlg_Search
return nil
Code: Select all
/****************************************************************************
dbcombo1.rc
produced by Borland Resource Workshop
*****************************************************************************/
#define DIALOG_1 1
SEARCH DIALOG 35, 52, 402, 227
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
CAPTION "Search"
FONT 8, "MS Sans Serif"
{
COMBOBOX 30, 307, 3, 92, 71, CBS_DROPDOWNLIST | WS_TABSTOP
LTEXT "Search for:", -1, 6, 5, 38, 8
EDITTEXT 10, 46, 4, 141, 12, WS_BORDER | WS_TABSTOP
LTEXT "Order:", -1, 285, 5, 22, 8
LISTBOX 40, 2, 27, 400, 199, LBS_STANDARD
PUSHBUTTON "Select", 20, 190, 3, 50, 14
}