I want the "orders" TAB to only show the orders for the selected customer
I have tried many things with no luck. I am not sure what approach to take.
Filtering is too slow.
ORDSCOPE ? DBSETRELATION?
Where in the code do I set this?
Thanks.
- Code: Select all Expand view
#include "FiveWin.ch"
static oWnd
static oDlg
STATIC oDBF_CLIENTS
STATIC oDBF_ORDERS
REQUEST DBFCDX
PROCEDURE main()
DEFINE WINDOW oWnd TITLE "TEST FOLDER" ;
MENU BuildMenu()
ACTIVATE wINDOW oWnd MAXIMIZED
return
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "Run" ACTION MyFolder()
MENUITEM "Exit" ACTION oWnd:End()
ENDMENU
return oMenu
function MyFolder()
local oDlg1, oDlg2, oFld
LOCAL oBtn1,oBtn2
create_data()
DBSELECTAREA("ORDERS")
DATABASE oDBF_ORDERS
oDBF_ORDERS:bEoF = nil
oDBF_ORDERS:Gotop()
oDBF_ORDERS:Load()
DBSELECTAREA("CLIENTS")
DATABASE oDBF_CLIENTS
oDBF_CLIENTS:bEoF = nil
oDBF_CLIENTS:Gotop()
oDBF_CLIENTS:Load()
DEFINE DIALOG oDlg of oWnd SIZE 500,300
@ 0,1 BUTTON oBtn1 PROMPT "PREV" OF oDlg ACTION SKIPREC(-1)
@ 0,15 BUTTON oBtn2 PROMPT "NEXT" OF oDlg ACTION SKIPREC(1)
@ 1,1 FOLDER oFld OF oDlg ;
PROMPTS "Client Info", "Orders";
DIALOGS "oDlg1", "oDlg2" ;
SIZE 400,200
@ 1,1 GET oDBF_CLIENTS:NUMBER OF oFld:aDialogs[ 1 ] UPDATE WHEN .F.
@ 1,5 GET oDBF_CLIENTS:COMPANY OF oFld:aDialogs[ 1 ] UPDATE
@ 1,1 LISTBOX FIELDS ALIAS "ORDERS" of oFld:aDialogs[ 2 ] UPDATE
ACTIVATE DIALOG oDlg VALID (DBCLOSEALL(),.T.)
return nil
STATIC PROCEDURE SKIPREC(nRECS)
oDBF_CLIENTS:SKIP(nRECS)
IF oDBF_CLIENTS:Eof()
oDBF_CLIENTS:GoBottom()
ENDIF
IF oDBF_CLIENTS:Bof()
oDBF_CLIENTS:GoTop()
ENDIF
oDlg:Update()
RETURN
STATIC PROCEDURE create_data()
RddSetDefault( "DBFCDX" )
DBCREATE('CLIENTS.DBF',{{"NUMBER", "C", 3, 0},{"COMPANY", "C", 30, 0}} )
USE CLIENTS ALIAS CLIENTS EXCLUSIVE NEW
APPEND BLANK
CLIENTS->NUMBER:='002'
CLIENTS->COMPANY:='DEF'
APPEND BLANK
CLIENTS->NUMBER:='001'
CLIENTS->COMPANY:='ABC'
APPEND BLANK
CLIENTS->NUMBER:='003'
CLIENTS->COMPANY:='GHI'
APPEND BLANK
CLIENTS->NUMBER:='004'
CLIENTS->COMPANY:='JKL'
INDEX ON CLIENTS->COMPANY TAG "COMPANY"
DBCREATE('ORDERS.DBF',{{"NUMBER", "C", 3, 0},{"GOODS", "C", 30, 0}} )
USE ORDERS ALIAS ORDERS EXCLUSIVE NEW
APPEND BLANK
ORDERS->NUMBER:='002'
ORDERS->GOODS:='DEF ITEM 1'
APPEND BLANK
ORDERS->NUMBER:='001'
ORDERS->GOODS:='ABC ITEM 1'
APPEND BLANK
ORDERS->NUMBER:='003'
ORDERS->GOODS:='GHI ITEM 1'
APPEND BLANK
ORDERS->NUMBER:='002'
ORDERS->GOODS:='DEF ITEM 2'
APPEND BLANK
ORDERS->NUMBER:='002'
ORDERS->GOODS:='DEF ITEM 3'
APPEND BLANK
ORDERS->NUMBER:='003'
ORDERS->GOODS:='GHI ITEM 2'
INDEX ON ORDERS->NUMBER TAG "NUMBER"
RETURN