Combo Box and DBF fields
-
- Posts: 334
- Joined: Fri Oct 14, 2005 1:54 pm
Combo Box and DBF fields
How can I use Combo Box to enter a value from a dbf field ?
-
- Posts: 108
- Joined: Sun Oct 09, 2005 6:12 pm
- Location: Mar del Plata - Argentina
- Contact:
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,
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,
- Manuel Valdenebro
- Posts: 706
- Joined: Thu Oct 06, 2005 9:57 pm
- Location: Málaga-España
dbCombo
Ehah
You can use \source\classes\dbcombo.prg
Regards
You can use \source\classes\dbcombo.prg
Regards
-
- Posts: 334
- Joined: Fri Oct 14, 2005 1:54 pm
To the Both two repliers
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
*------------------
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
- Manuel Valdenebro
- Posts: 706
- Joined: Thu Oct 06, 2005 9:57 pm
- Location: Málaga-España
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 )
. . . . . .
@ 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 )
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