Combo Box and DBF fields

Combo Box and DBF fields

Postby Ehab Samir Aziz » Mon Nov 07, 2005 8:12 pm

How can I use Combo Box to enter a value from a dbf field ?
Ehab Samir Aziz
 
Posts: 334
Joined: Fri Oct 14, 2005 1:54 pm

Postby DanielPuente » Tue Nov 08, 2005 2:16 am

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,
Daniel Puente
Mar del Plata, Argentina
danielpuente@speedy.com.ar
puenteda@hotmail.com
DanielPuente
 
Posts: 108
Joined: Sun Oct 09, 2005 6:12 pm
Location: Mar del Plata - Argentina

dbCombo

Postby Manuel Valdenebro » Tue Nov 08, 2005 5:44 am

Ehah

You can use \source\classes\dbcombo.prg

Regards
User avatar
Manuel Valdenebro
 
Posts: 706
Joined: Thu Oct 06, 2005 9:57 pm
Location: Málaga-España

To the Both two repliers

Postby Ehab Samir Aziz » Sat Nov 12, 2005 10:58 am

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
Ehab Samir Aziz
 
Posts: 334
Joined: Fri Oct 14, 2005 1:54 pm

Postby Manuel Valdenebro » Sat Nov 12, 2005 1:09 pm

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 )
User avatar
Manuel Valdenebro
 
Posts: 706
Joined: Thu Oct 06, 2005 9:57 pm
Location: Málaga-España

Postby dbSoft » Sat Nov 12, 2005 5:30 pm

Code: Select all  Expand view  RUN

#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



User avatar
dbSoft
 
Posts: 16
Joined: Thu Oct 13, 2005 8:31 pm
Location: Greece


Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 13 guests