-2

And I want to copy the startDate and Enddate copiing to the other line,

I have this:

GetDates(Bom : Record "BOM Component";VAR StartDateItem : Date;VAR EndDateItem : Date;RegelkortingItem : Decimal)

IF GET(Bom."Parent Item No.",Bom."Line No.") THEN BEGIN
  StartDateItem :=StartDate2;
  EndDateItem := EndDate2;
  RegelkortingItem := Regelkorting;
END;

SetDates(Bom : Record "BOM Component";VAR StartDateItem : Date;VAR EndDateItem : Date;RegelkortingItem : Decimal)
"Parent Item No." := Bom."Parent Item No.";
"Line No." := Bom."Line No.";
StartDate2 := StartDateItem;
EndDate2 := EndDateItem;
Regelkorting := RegelkortingItem;

IF NOT MODIFY THEN 
  INSERT;

And this is a image

enter image description here

The black marker line - there the same date has to be copiied

Thank you

And this is the onvalidate:

BeginDate - OnValidate()
SetDates(Rec, StartDate2, EndDate2, Regelkorting);

So I try this:

Rec.SETRANGE(StartDate2,StartDate2);
IF StartDate2 <> StartDate2  THEN
//IF (Rec.COUNT > 1) THEN //AND  (FORMAT(Rec.StartDate2) = FORMAT(Rec.StartDate2)))  THEN
ERROR('The dates has to be the same!! ');
//END;

So the dates has to be the same.

I have it now like this:

IF StartDate2 <> BOMB.StartDate2  THEN
//IF (Rec.COUNT > 1) THEN //AND  (FORMAT(Rec.StartDate2) = FORMAT(Rec.StartDate2)))  THEN
ERROR('The dates has to be the same!! ');

But then If I just put one startdate, then the error message is already showing

ok, I have the complete code now like this:

SetDates(Rec, StartDate2, EndDate2, Regelkorting);
//StartDateInsert := Rec.StartDate2;
BOMB.RESET;
BOMB.SETRANGE(StartDate2,StartDate2);
IF BOMB.FINDFIRST THEN; 
IF StartDate2 <> BOMB.StartDate2 
THEN ERROR('The dates has to be the same!! ');

But nothing happens

See image. After the last line, it is ending debug. and nothing happens: enter image description here

For example I want to compare dates: like this:

enter image description here

Oke, this works. But only on the first record

SetDates(Rec, StartDate2, EndDate2, Regelkorting);
BOMB.RESET;
BOMB.SETRANGE(StartDate2,StartDate2);
IF BOMB.FINDFIRST THEN BEGIN
IF BOMB.StartDate2 > BOMB.EndDate2 THEN BEGIN
ERROR('startdatum kan niet groter zijn dan einddatum');
END;
END
SavantCode
  • 131
  • 2
  • 4
  • 14

1 Answers1

0

Firt check when you invoke SetDates() function StartDate2 and EndDate2 have a correct values. Perhaps here is the error.

You code is this:

BeginDate - OnValidate()
SetDates(Rec, StartDate2, EndDate2, Regelkorting);

Here you pass a Rec, StartDate2 and EndDate2 They have values of Rec and not the correct values.

Try to change for this code:

BeginDate - OnValidate()
SetDates(Rec, StartDateItem, EndDateItem, Regelkorting);
Jonathan Bravetti
  • 2,228
  • 2
  • 15
  • 29
  • The last code That's wrong, `rec.SETRANGE(StartDate2, StartDate2)` you filter `rec` with the same value of `rec`, Create a variable of `rec` like recBomTable, BOM. and filter this variable. – Jonathan Bravetti Sep 30 '16 at 14:18
  • Try this: `BOMB.RESET; BOMB.SETRANGE(StartDate2, StartDate2); IF BOMB.FINDFIRST THEN; IF StartDate2 <> BOMB.StartDate2 THEN ERROR('The dates has to be the same!! ');` – Jonathan Bravetti Sep 30 '16 at 14:34
  • I think the record no exist. try this to check. BOMB.RESET; BOMB.SETRANGE(StartDate2, StartDate2); IF BOMB.FINDFIRST THEN BEGIN IF StartDate2 <> BOMB.StartDate2 THEN ERROR('The dates has to be the same!! '); END ELSE ERROR('There is no record with StartDate2 %1', FORMAT(StartDate2)); – Jonathan Bravetti Sep 30 '16 at 14:47
  • Hi, I triied that. But no message will popup – SavantCode Oct 03 '16 at 06:35
  • Hi, think about this, you filter BOM table by date, for example 01/01/2016, you get a record by this date then you compare if this dates are diferent. These date are always going to be the same. example BOMB.SETRANGE(StartDate2, 01012016D); after FINDFIRST the value for BOMB.StartDate2 is the same filter value, in this example 01/01/2016 (01012016D). – Jonathan Bravetti Oct 03 '16 at 11:44
  • Hi. Oke, But is the placement: BeginDate-onvalidate not the correct place to define it? – SavantCode Oct 03 '16 at 12:30
  • I update the post. But sorry. What is wrong with it? I added a image. I see that it is of BOMB. SO I compare this values – SavantCode Oct 03 '16 at 13:51
  • Hi, I'm really confused. I do not understand you're trying to do. I recommend you remove this post. And create a new post with a better description. – Jonathan Bravetti Oct 03 '16 at 14:15
  • Yes, ok. I understand that. I will make a new post. Thank you – SavantCode Oct 07 '16 at 06:54