RE:Validar campos vacios en un datawindow
Prueba con este: crea un funcion: con estos datos:
Access: Public, Return Type: Integer, Functio Name: f_required, Pass By: Value, Argument Type: datawindow, Argument Name: adw_control
Luego pegas todo esto:
/////////////////////////////////////////////////////////////////
// /
// This function ensures that no required column in a /
// DataWindow control is empty (contains NULL). It takes /
// one argument: the DataWindow control. /
// /
// Return values: /
// /
// * -1 if validation fails /
// * 1 if required columns are filled in /
// /
/////////////////////////////////////////////////////////////////
integer li_colnbr = 1
long ll_row = 1
string ls_colname, ls_textname
///////////////////////////////////////////////////////////////
// /
// Make sure the last entry in the DataWindow control is /
// accepted before proceeding. /
// /
///////////////////////////////////////////////////////////////
IF adw_control.AcceptText() = -1 THEN
adw_control.SetFocus()
RETURN -1
END IF
///////////////////////////////////////////////////////////////
// /
// Now we can examine the required columns in each row of /
// the DataWindow control. /
// /
// The following function starts at row 1, column 1 in the /
// DW's primary buffer. Then it looks through each row /
// until it finds a required column that is empty. /
// /
///////////////////////////////////////////////////////////////
IF adw_control.FindRequired( primary!, ll_row, li_colnbr, &
ls_colname, true ) < 0 THEN
// If the search can't be done due to some error,
// then quit this script.
RETURN -1
END IF
///////////////////////////////////////////////////////////////
// /
// The preceding function updates the ll_row variable with /
// the number of the first row in which a required column was /
// found empty (or 0 if all rows were OK). Here's a test /
// to see if such a row was found. /
// /
///////////////////////////////////////////////////////////////
IF ll_row <> 0 THEN
// Get the text of that column's label.
ls_textname = ls_colname + "_t.Text"
ls_colname = adw_control.Describe(ls_textname)
// Tell the user which column to fill in.
MessageBox("Falta Valor Requerido","Por favor ingrese un valor para '" &
+ ls_colname +"', Fila " + string (ll_row) + ".", stopsign! )
// Make the problem column current.
adw_control.SetColumn(li_colnbr)
adw_control.ScrollToRow(ll_row)
adw_control.SetFocus()
RETURN -1
END IF
///////////////////////////////////////////////////////////////
// /
// If every column in every row checked out OK... /
// /
///////////////////////////////////////////////////////////////
RETURN 1
Por ejemplo: en un boton de grabar: cb_save, la primera linea de codigo le pones:
IF f_checkrequired (dw_orddetail) = -1 THEN RETURN
Listo eso es todo, espero que te sirva.
Saludos desde Peru.
Edgar Flores