Consultas con Grid

GuRaMa
23 de Junio del 2004
El tema es sencillo aunque yo no pueda verlo, tengo un textbox un boton y un grid, lo que necesito es que el dato introducido en el textbox sea mostrado en el grid cuando se presiona el boton alguien me puede ayudar por favor???

Gracias

enieto1
23 de Junio del 2004
este ejemplo te puede servir

**solo caracteres evento key press
#DEFINE DELKEY 127
#define w_tabla empleados
#define w_campo nombre
LPARAMETERS nKeyCode, nShiftAltCtrl
LOCAL cDisplayValue
IF nKeyCode = DELKEY
cDisplayValue = ALLTRIM(THIS.DisplayValue)
IF LEN(m.cDisplayValue)=1
cDisplayValue = ""
ELSE
cDisplayValue = LEFT(cDisplayValue,LEN(cDisplayValue)-1)
ENDIF
ELSE
cDisplayValue = ALLTRIM(THIS.DisplayValue)+CHR(nKeyCode)
ENDIF

THISFORM.LockScreen = .T.
DO CASE
CASE EMPTY(m.cDisplayValue)
THISFORM.grdcust.recordsource = " "
CASE THIS.Value = "(All)"
SELECT w_campo AS location,* FROM w_tabla;
INTO CURSOR Custs
thisform.grdcust.recordsource = "Custs"
OTHERWISE
SELECT w_campo AS location,* FROM w_tabla ;
WHERE UPPER(ALLTRIM(w_tabla.w_campo)) = UPPER(m.cDisplayValue);
INTO CURSOR Custs
thisform.grdcust.recordsource = "Custs"
ENDCASE
THISFORM.LockScreen = .F.

**evento lost focus
#define w_tabla empleados
#define w_campo nombre
LOCAL cDisplayValue,cSqlStr,cCountryName
cDisplayValue = ALLTRIM(THIS.DisplayValue)
THIS.SelLength = 0
IF EMPTY(m.cDisplayValue)
RETURN
ENDIF

THISFORM.LockScreen = .T.

IF THIS.Value = "(All)"
SELECT w_tabla AS location,* FROM w_tabla INTO CURSOR Custs
thisform.grdcust.recordsource = "Custs"
ELSE
SELECT w_campo AS location,* FROM w_tabla ;
WHERE UPPER(ALLTRIM(w_tabla.w_campo)) = UPPER(m.cDisplayValue);
INTO CURSOR Custs
thisform.grdcust.recordsource = "Custs"
IF _TALLY #0
cCountryName = ALLTRIM(Custs.w_campo)
IF ATC(m.cCountryName,THIS.RowSource) = 0 AND !EMPTY(m.cCountryName)
THIS.RowSource=THIS.RowSource+","+m.cCountryName
ENDIF
THIS.Value = m.cCountryName
ENDIF
ENDIF
THISFORM.LockScreen = .F.

y el boton solo me sirve para capturar los datos de la tabla para este caso y cerrar el formulario