Hi Experts,
I have created "Starting Date" and "Ending Date" fields in "SalesTarget" table with a primary key "Target name". I need to validate those two fields. The validation should check these following conditions.
1. Starting date and Ending date can be same or different.
2. While we enter the new record for starting date field in the table, the starting date should not be within the range of previous starting date and ending date entered. The system should check for all the records in the table. The starting date should be lesser than the ending date.
For this, I have added the following code. But, I got failures in the result in some scenarios:
when I try to enter in out of range of starting and ending dates, the system does not allows to enter it.
Starting Date - OnValidate()
Date1 := "Starting Date";
Date2 := "Ending Date";
SalesTarget.RESET;
IF SalesTarget.FIND('-') THEN BEGIN
REPEAT
WHILE (Date1 <= Date2 )
DO BEGIN
IF (Date1 <> 0D) AND (Date1 >= SalesTarget."Starting Date") AND (Date1 <= SalesTarget."Ending Date") THEN
ERROR(Text002);
Date1 := CALCDATE('1D',Date1);
END;
UNTIL SalesTarget.NEXT= 0;
END;
SalesTarget.RESET;
IF SalesTarget.FIND('-') THEN BEGIN
REPEAT
IF ("Starting Date" < SalesTarget."Ending Date") THEN
ERROR(Text002);
UNTIL SalesTarget.NEXT = 0;
END;
Help pls :shock:
With warm regards,
Thankesh
***Learn to lead***
0
Comments
in the second line i have entered starting date 010111 and ending date 311211
it is allowing to take..what else you want?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
In the first line I have entered Starting date 01/01/01 and ending date 10/01/01
In the second line I have entered starting date 15/01/01 and ending date 20/01/01
In the third line I need to enter starting date 12/01/01 and ending date 14/01/01. (12/01/01 .. 14/01/01 is not within the range of first and second line starting and ending dates. But the system is giving error).
Thankesh
***Learn to lead***
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
I need this kind of validation as stated in the previous example. Pl help. :?:
Thankesh
***Learn to lead***
Hi Mohana,
How to achieve this :!:
Thankesh
***Learn to lead***
you can try by commentiong this code..
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
SalesTarget.RESET;
IF SalesTarget.FIND('-') THEN BEGIN
REPEAT
IF ("Starting Date" < SalesTarget."Ending Date") THEN
ERROR(Text002);
UNTIL SalesTarget.NEXT = 0;
END;
The date 12/01/01 is lesser then 20/01/01.
U need not loop through all the dates just for that record u need to check the ending date..
Please use mohana logic for this validation.
or use
SalesTarget.RESET;
SalesTarget.setrange(Target name,target name);//
IF SalesTarget.FIND('-') THEN BEGIN
//REPEAT
IF ("Starting Date" < SalesTarget."Ending Date") THEN
ERROR(Text002);
//UNTIL SalesTarget.NEXT = 0;
END;
Hi Mohana,
I have already tried by removing the above code. But, I did not get the exact result which I stated in the example.
If I comment this code, the starting date field will allow all the dates that we enter into that field. I need the validation as per I stated in the previous example. :roll:
Thankesh
***Learn to lead***
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav