Hi,
I want to test if startdate in a row already exists. So if value already exist in database
I have this:
SetDates(Rec, StartDate2, EndDate2, Regelkorting);
Rec.FINDFIRST
//MESSAGE(FORMAT(Rec.StartDate2));
//MESSAGE(FORMAT(xRec.StartDate2));
IF FORMAT(Rec.StartDate2) = FORMAT(Rec.StartDate2) THEN BEGIN
MESSAGE('THe same');
END;
But that doesnt work
I triied on the beginDate-onvalidate,
like this:
BeginDate - OnValidate()
SetDates(Rec, StartDate2, EndDate2, Regelkorting);
Rec.SETRANGE(StartDate2,BOM.StartDate2,BOM.StartDate2);
IF Rec.COUNT > 1 THEN
ERROR('Number already exists ');
SetDates(Rec, StartDate2, EndDate2, Regelkorting);
Rec.SETRANGE(StartDate2,StartDate2);
IF Rec.COUNT > 1 THEN
ERROR('Number already exists ');
But I want to have the dates the same. I try it like this:
SetDates(Rec, StartDate2, EndDate2, Regelkorting);
Rec.SETRANGE(StartDate2,StartDate2);
IF ((Rec.COUNT > 1) AND (FORMAT(Rec.StartDate2) <> FORMAT(Rec.StartDate2))) THEN
ERROR('The dates has to be the same!! ');
If I do this:
SetDates(Rec, StartDate2, EndDate2, Regelkorting);
Rec.SETRANGE(StartDate2,StartDate2);
IF (Rec.COUNT > 1) THEN //AND (FORMAT(Rec.StartDate2) = FORMAT(Rec.StartDate2))) THEN
ERROR('The dates has to be the same!! ');
it checks if they are the same.
But I want that the dates are the same
In trigger “Starting Date - OnValidate” write:
// loc. variable: BomLine, rec, “Production BOM Line”
BomLine.setrange(“Starting Date”,“Starting Date”);
if BomLine.findfirst then
error(“Starting Date already exists.”);
Thank you. Will have a look on it