Ayuda: Limpiar un Grid y Textbox

247 views
Skip to first unread message

Jose Gabriel Moreno Puentes

unread,
Aug 9, 2021, 5:27:18 PM8/9/21
to Comunidad de Visual Foxpro en Español
Hola buen día comunidad, he regresado el novato en VFP en busca de su ayuda jaja.
Tengo la siguiente situación: tengo un grid que lleno mediante una consulta y con los datos del grid lleno unos textbox relacionando el ControlSource de los texbox al cursor.
El problema que tengo es que quiero limpiar esos datos que hay en el grid y en los textbox, utilizo un ZAP para limpiar todo pero cuando lo utilizo me des-habilita todos los text box.

Así tengo mi Form: mediante un combobox decido lo que quiero hacer, ya sea una consulta, bajas, altas o cambios
Untitled.png

Cuando elijo consulta, bajas o cambios se me llena todo automáticamente, hasta ahí todo bien, habilito o des-habilito algunos botones y sea el caso de hacer consultas, bajas o cambios.
Capture.PNG

Pero cuando quiero hacer un registro nuevo quiero que se limpie mi grid y también mis textbox para que pueda ingresar datos nuevos, pero el problema es que se me des-habilita todo
Capture.PNG

Este es el codigo que tengo en mi combobox en el evento click:

LOCAL vSelect

vSelect = thisform.combo1.Value

DO CASE
CASE vSelect = 'Consulta'
thisform.grid1.SetFocus()
thisform.llena_grid()
thisform.format_grid()
thisform.grid1.Enabled = .T.
thisform.llena_text()
thisform.btnImprimir.Enabled = .T.
thisform.btnBuscar.Enabled = .T.
thisform.btnBaja.Visible = .F.
thisform.btnGuardar.Visible = .F.
thisform.btnCancelar.Visible = .F.
CASE vSelect = 'Nuevo'
thisform.format_grid()
thisform.grid1.Enabled = .T.
SELECT "rep"
ZAP
thisform.grid1.RecordSource = "rep"
thisform.Refresh()
thisform.text1.ReadOnly = .F.
thisform.text2.ReadOnly = .F.
thisform.text3.ReadOnly = .F.
thisform.text4.ReadOnly = .F.
thisform.text5.ReadOnly = .F.
thisform.text6.ReadOnly = .F.
thisform.text7.ReadOnly = .F.
thisform.text8.ReadOnly = .F.
thisform.text9.ReadOnly = .F.
thisform.text10.ReadOnly = .F.
thisform.text1.Enabled = .T.
thisform.text2.Enabled = .T.
thisform.text3.Enabled = .T.
thisform.text4.Enabled = .T.
thisform.text5.Enabled = .T.
thisform.text6.Enabled = .T.
thisform.text7.Enabled = .T.
thisform.text8.Enabled = .T.
thisform.text9.Enabled = .T.
thisform.text10.Enabled = .T.

thisform.txtR.Enabled = .F.
thisform.txtC.Enabled = .F.
thisform.txtU.Enabled = .F.
thisform.btnBaja.Visible = .F.
thisform.btnGuardar.Visible = .T.
thisform.btnBuscar.Enabled = .F.
thisform.btnimprimir.Enabled = .F.
thisform.btnCancelar.Visible = .T.
thisform.combo1.Enabled= .F.
thisform.text1.SetFocus()
CASE vSelect = 'Baja'
thisform.llena_grid()
thisform.grid1.Enabled = .T.
thisform.grid1.SetFocus()
thisform.format_grid()
thisform.llena_text()
thisform.btnImprimir.Enabled = .T.
thisform.btnBuscar.Enabled = .T.
thisform.btnBaja.Visible = .T.
thisform.btnGuardar.Visible = .F.
thisform.btnCancelar.Visible = .F.
CASE vSelect = 'Cambios'
thisform.grid1.SetFocus()
thisform.llena_grid()
thisform.format_grid()
thisform.grid1.Enabled = .T.
thisform.llena_text()
thisform.text1.ReadOnly = .F.
thisform.text2.ReadOnly = .F.
thisform.text3.ReadOnly = .F.
thisform.text4.ReadOnly = .F.
thisform.text5.ReadOnly = .F.
thisform.text6.ReadOnly = .F.
thisform.text7.ReadOnly = .F.
thisform.text8.ReadOnly = .F.
thisform.text9.ReadOnly = .F.
thisform.text10.ReadOnly = .F.
thisform.txtR.ReadOnly = .F.
thisform.txtC.ReadOnly = .F.
thisform.txtU.ReadOnly = .F.
thisform.btnImprimir.Enabled = .T.
thisform.btnBuscar.Enabled = .T.
thisform.btnBaja.Visible = .F.
thisform.btnGuardar.Visible = .T.
thisform.btnCancelar.Visible = .T.
ENDCASE


Si alguien sabe que tengo mal o como le puedo hacer se los agradecería.


Hendell Mora

unread,
Aug 9, 2021, 5:44:01 PM8/9/21
to publice...@googlegroups.com
Append blank después del zap 

--
Blog de la Comunidad Visual FoxPro en Español: http://comunidadvfp.blogspot.com
---
Has recibido este mensaje porque estás suscrito al grupo "Comunidad de Visual Foxpro en Español" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a publicesvfoxp...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/publicesvfoxpro/b7f36100-3b77-4bfb-9523-793aba1e7ba0n%40googlegroups.com.

Jose Gabriel Moreno Puentes

unread,
Aug 9, 2021, 6:14:20 PM8/9/21
to Comunidad de Visual Foxpro en Español
Gracias por responder Hendel, ya cambie así como dices y no sigue igual :(
Me des-habilita todo
Capture.PNG

También cambie el código le deje como DELETE ALL y ahí si funciona pero me deja el ultimo registro en el grid:
Capture.PNG

Después intente poner "DELETE ALL" y después "APPEND BLANK" y si funciona pero al momento de cancelar la accion y seleccionar por ejemplo consultas me sale ese error:
Capture.PNG

AZOK

unread,
Aug 9, 2021, 6:55:41 PM8/9/21
to publice...@googlegroups.com

Tal vez eso sucede por que los text box los tienes relacionados directamente a los campos del cursor y al hacer el ZAP borras los datos (registros) del cursor y ya no hay nada a mostrar.

Para que se habiliten deben tener un registro o campo que mostrar, aunque este en blanco y con ZAP los estas eliminando.

Yal vez si después del append blank que te recomienda Hendel un refresh al form te los habilite

Saludos


El 09/08/21 a las 17:14, Jose Gabriel Moreno Puentes escribió:

mario oviedo

unread,
Aug 9, 2021, 7:51:26 PM8/9/21
to publice...@googlegroups.com
porque no modificas en grid, mas facil, no utilices txt, yo te enseño como, desde 0

Hendell Mora

unread,
Aug 9, 2021, 7:54:27 PM8/9/21
to publice...@googlegroups.com
Eso es por que tienes un registro en blanco al hacer el append blank.

Debes hacer un tablerevert() a la tabla para que revierta los cambios a la hora de cancelar la inclusión 

Jose Gabriel Moreno Puentes

unread,
Aug 10, 2021, 11:41:11 AM8/10/21
to Comunidad de Visual Foxpro en Español
Muchas gracias a todos por sus aportaciones, se los agradesco mucho, Hendel como es la sitaxis correcta para el tablerevert()?.
Yo utilice el tableupdate() para realizar un update en los cambios, pero tengo entendido que no es la misma sintaxis.
En mi boton guardar para guardar los cambios echos tengo el siguiente codigo:
vReg = thisform.combo1.Value

DO CASE
CASE vReg = 'Cambios'
vFolio = thisform.text1.Value
vSucu = thisform.text2.Value
vCam = thisform.text3.Value
vRec = thisform.text9.Value
vEnt = thisform.text10.Value
vObs = thisform.text4.Value
vDes = thisform.text5.Value
vSub = thisform.text6.Value
vIva = thisform.text7.Value
vTot = thisform.text8.Value
TEXT TO sqlupd NOSHOW 
UPDATE SIMTAL
SET SUCURSAL = ?vSucu, CAMION = ?vCam, OBSERVA = ?vObs, DESCUENTO = ?vDes , SUBTOTAL = ?vSub , IVA = ?vIva , TOTAL = ?vTot , RECIBIR = ?vRec , ENTREGAR = ?vEnt
WHERE FOLIO = ?vFolio
ENDTEXT
vComp = SQLEXEC(mConexion1,sqlupd,"rep")
If vComp < 0
    =  Aerror(laError)
    Messagebox("ERROR! " + laError[2])
    CANCEL
    ELSE 
    MESSAGEBOX("Se actualizo correctamente! :D")
    TABLEUPDATE(1,.T.,"rep")
    thisform.Refresh
ENDIF
ENDCASE


Quise hacer lo mismo que el TABLEUPDATE() pero en TABLEREVERT() y en el boton cancelar pero no funciona D:

mario oviedo

unread,
Aug 10, 2021, 11:56:05 AM8/10/21
to publice...@googlegroups.com
te ayudo pero la actualizacion la debes hacer en el grid 

Hendell Mora

unread,
Aug 10, 2021, 11:57:06 AM8/10/21
to publice...@googlegroups.com
TABLEREVERT("rep")

Jose Gabriel Moreno Puentes

unread,
Aug 10, 2021, 1:13:22 PM8/10/21
to Comunidad de Visual Foxpro en Español
Muchas gracias, por sus respuestas, al final el código lo deje de la siguiente manera y me funciona bien:

select "rep"
set multilocks on
=CURSORSETPROP('Buffering', 5 )
=tablerevert(.t.,"rep")

Maovie me interesa lo que me dices de actualizar los datos desde el grid, por ahora lo dejare como lo tengo pero si no seria mucha molestia me podrías explicar como se hace en el grid, lo de modificar datos, claro si es mas sencillo de como lo estoy haciendo yo.

mario oviedo

unread,
Aug 10, 2021, 2:31:12 PM8/10/21
to publice...@googlegroups.com
escribime te dare un ejemplo

Reply all
Reply to author
Forward
0 new messages