Data Range Validation
Posted: Mon Mar 27, 2023 3:08 pm
I'm trying to set a set of cells to only accept dates in a certain range. My code
FXLS.CmdFormat.Mode := xcfmReplace;
FXLS.CmdFormat.BeginEdit(DataSheet);
FXLS.CmdFormat.Number.Format := 'YYYY-MM-DD';
FXLS.CmdFormat.Apply(Col, FIRSTDATA_ROW, Col, AVAILABLE_ROWS - 1);
dv := DataSheet.Validations.Add;
dv.Areas.Add(Col, FIRSTDATA_ROW, Col, AVAILABLE_ROWS - 1);
dv.Type_ := x12dvtDate;
dv.Operator_ := x12dvoBetween;
dv.Formula1 := '1900-01-01';
dv.Formula2 := '2499-12-31';
dv.ShowErrorMessage := True;
dv.ErrorTitle := 'Invalid Value';
dv.Error := 'Valid date required in ISO format between 1900-01-01 and 2499-12-31';
Does not work. It will not accept any dates that are valid in the range. I've also tried dates in UK format DD/MM/YYYY.
What is the correct method of doing this?
Mike
FXLS.CmdFormat.Mode := xcfmReplace;
FXLS.CmdFormat.BeginEdit(DataSheet);
FXLS.CmdFormat.Number.Format := 'YYYY-MM-DD';
FXLS.CmdFormat.Apply(Col, FIRSTDATA_ROW, Col, AVAILABLE_ROWS - 1);
dv := DataSheet.Validations.Add;
dv.Areas.Add(Col, FIRSTDATA_ROW, Col, AVAILABLE_ROWS - 1);
dv.Type_ := x12dvtDate;
dv.Operator_ := x12dvoBetween;
dv.Formula1 := '1900-01-01';
dv.Formula2 := '2499-12-31';
dv.ShowErrorMessage := True;
dv.ErrorTitle := 'Invalid Value';
dv.Error := 'Valid date required in ISO format between 1900-01-01 and 2499-12-31';
Does not work. It will not accept any dates that are valid in the range. I've also tried dates in UK format DD/MM/YYYY.
What is the correct method of doing this?
Mike