Page 1 of 1
Combo Box and DBF fields
Posted: Mon Nov 07, 2005 8:12 pm
by Ehab Samir Aziz
How can I use Combo Box to enter a value from a dbf field ?
Posted: Tue Nov 08, 2005 2:16 am
by DanielPuente
Ehab:
Up to 256 elements:
Local aRubro:=CARGACOMBO( .f., "RUBRO",2,"NOMBRE" )
REDEFINE COMBOBOX oRubro VAR cRubro ITEMS aRubro ID 111 OF oFld:aDialogs[1]
Function CARGACOMBO(VACIO,XARCH, XORDEN, XCAMPO)
Local ORD_ACT, AREA_ACT := SELECT()
Local VECTOR:={}
DBSELECTAR(XARCH)
ORD_ACT = INDEXORD()
SET ORDER TO XORDEN
DBGOTOP()
IF VACIO
AADD(VECTOR,SPACE(LEN(EVAL(FIELDBLOCK(XCAMPO)))))
ENDIF
DO WHILE !(XARCH)->(EoF())
AADD(VECTOR,EVAL(FIELDBLOCK(XCAMPO)))
(XARCH)->(DbSkip())
ENDDO
SET ORDER TO ORD_ACT
SELECT(AREA_ACT)
RETURN VECTOR
Regards,
dbCombo
Posted: Tue Nov 08, 2005 5:44 am
by Manuel Valdenebro
Ehah
You can use \source\classes\dbcombo.prg
Regards
To the Both two repliers
Posted: Sat Nov 12, 2005 10:58 am
by Ehab Samir Aziz
To the first reply :
*------------------
I tried your help about combo Boxes but I got that error message :
Argument error : ALLTRIM()
I do not find any alltrim in the whole program .
To the second reply :
*------------------
I could not find any /source/classes directory in my evaluation version ,So I could not practise any dbcombo programs .
#include "FiveWin.ch"
#include "e:\programs\clipper\fweval\include\combos.ch"
#include "dbcombo.ch"
//------------------------------------------------------------------------//
function Main()
local oDlg
local oGet
local dDay := Date()
local dnum := 0
local dnam := space(40)
local dpho := space(10)
Local oCombo:=CARGACOMBO( .f., "CUST",1,"cu_Name" )
select 1
use cust
DEFINE DIALOG oDlg TITLE "Phone Book" FROM 0, 0 TO 23, 79
@ 1, 2 SAY "Number:" OF oDlg
@ 1, 6 GET oGet VAR dnum OF oDlg SIZE 20, 12 PICT "9999"
@ 2, 2 SAY "Date:" OF oDlg
@ 2, 6 GET oGet VAR dDay OF oDlg SIZE 40, 12
@ 3, 2 SAY "Name:" OF oDlg
@ 3, 6 GET oGet VAR dNam OF oDlg SIZE 120, 12 pict "@!"
@ 4, 2 SAY "Phone #:" OF oDlg
@ 4, 6 GET oGet VAR dpho OF oDlg SIZE 70, 12
@ 7, 6 BUTTON "&End" OF oDlg SIZE 30, 12 ACTION oDlg:End()
@ 8, 18 COMBOBOX oCombo VAR oCombo ITEMS oCombo OF oDlg
ACTIVATE DIALOG oDlg
*ON CHANGE MsgInfo( cCombo )
*oGet:bGotFocus := { || oGet:SelectAll() }
return nil
//------------------------------------------------------------------------//
/*Local aRubro:=CARGACOMBO( .f., "RUBRO",2,"NOMBRE" )
REDEFINE COMBOBOX oRubro VAR cRubro ITEMS aRubro ID 111 OF oFld:aDialogs[1] */
Function CARGACOMBO(VACIO,XARCH, XORDEN, XCAMPO)
Local ORD_ACT, AREA_ACT := SELECT()
Local VECTOR:={}
select 1
use cust
DBSELECTAR(XARCH)
ORD_ACT = INDEXORD()
SET ORDER TO XORDEN
DBGOTOP()
IF VACIO
AADD(VECTOR,SPACE(LEN(EVAL(FIELDBLOCK(XCAMPO)))))
ENDIF
DO WHILE !(XARCH)->(EoF())
AADD(VECTOR,EVAL(FIELDBLOCK(XCAMPO)))
(XARCH)->(DbSkip())
ENDDO
SET ORDER TO ORD_ACT
SELECT(AREA_ACT)
RETURN VECTOR
Posted: Sat Nov 12, 2005 1:09 pm
by Manuel Valdenebro
An old versión (ten years ago), but try this:
. . . . . .
@ nFile, nCol COMBOBOX oCbx VAR cCbx ;
ITEMS aBase ("client.dbf", 42, "fieldnom" )
. . . . . . . .
// -----------------------------------------------------------------------
// Function ..: aBase
// Descriptión: Create an array from dbf
// Parameter .: cFichero (dbf name)
// nAncho (array width)
// cCampo (field name)
// Return ..: acDevuelve -> array
// Manuel Valdenebro ... MALAGA/SPAIN
// -----------------------------------------------------------------------
FUNCTION aBase ( cFichero, nAncho, cCampo )
LOCAL acDevuelve := {}, nAreaActiva := Select()
aAdd( acDevuelve, space( nAncho ) ) // Put First element empty
SELE (cFichero)
dbGoTop()
WHILE !Eof()
aAdd( acDevuelve, (cFichero)->&cCampo )
dbSkip()
ENDDO
SELE ( nAreaActiva )
RETURN( acDevuelve )
Posted: Sat Nov 12, 2005 5:30 pm
by dbSoft
Code: Select all
#include "dbcombo.ch
if empty(cSTOR_ID ) ; cSTOR_ID := 1 ; endif
DEFINE DIALOG oDlg RESOURCE 'TTAB'
DBSELECTAREA( dbSTORE )
REDEFINE DBCOMBO oSTOR_ID VAR cSTOR_ID ;
ID 107 OF oFld:aDialogs[1] ;
ALIAS (dbSTORE) ;
ITEMFIELD "STORE_ID" ;
LISTFIELD "STORE_DESC"
ACTIVATE DIALOG oDlg CENTERED