I tried Creating Line No. programatically using this code:
//Function GetLineNo
recBMGICollectionDetails2.RESET;
recBMGICollectionDetails2.SETRANGE(recBMGICollectionDetails2."Document No.","No.");
IF recBMGICollectionDetails2.FIND('+') THEN BEGIN
"Line No." := ROUND(recBMGICollectionDetails2."Line No.",1000,'=') + 1000;
END ELSE BEGIN
"Line No." := 1000;
END;
That code is inside in a LOOP condition :
FOR I := 1 TO vTerms DO BEGIN
vCount := vCount + 1;
WITH recBMGICollectionDetails DO BEGIN
INIT;
vBMGIDate := Date;
"Line No." := GetLineNo;
IF vBMGIDate = 0D THEN BEGIN
Date := CALCDATE(vMonths,vDate);
END ELSE BEGIN
Date := CALCDATE(vMonths,vBMGIDate);
END;
"Document Code" := GetNextCode(vStartingNo,vCount);
Amount := ("Lawn Lot Amount"/vTerms);
INSERT;
END;
END;
CurrPage.UPDATE;
But error gave the error Line No. Already Exist. As you see, I already put INSERT so on the next loop the GETLINENO will give me the next the new Value of LINE No. can somebody help me with this? thanks in advance.
0
Answers
IF recBMGICollectionDetails2.FINDLAST THEN BEGIN
"Line No." := recBMGICollectionDetails2."Line No." + 1000;
END ELSE BEGIN
"Line No." := 1000;
END
You can use Autosplitkey property to generate key automatically.
yes. I already did that and the error is still the same. I already set the autosplitkey as yes. I progmatically create this because i want to replicate CREATE CHECK INSTALLMENTS in Post dated checks-Purchase.
Second is to get the last "Line No." from the table to an integer before you enter the creation loop and then use the integer in the creation loop. This would reduce database- access and would work if you do not create additional lines in the table while inserting the actual record.
And third: Autosplitkey is only used on Pages while Inserting in a List.
i want to create multiple line in recBMGICollectionDetails in one click of the button. that's why i put insinde the GETLINENO function inside the loop.
"Line No." := I;
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
I assign it as you said sir. and it works properly. any suggestion ?
try passing record variable as parameter and try debugging
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
What i'm trying to say was, that if your (not called) recBMGICollectionDetails- Insert-Trigger would insert more Lines in recBMGICollectionDetails then you can't use the integer variable.
Did you try to assign the "Document no."?
I have a question. what is the difference between this two?
FIND('+') AND FIND('+')
Both are same
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
ow. sorry sir. what i mean si FIND('-') and FIND('+')
Yes. this error shows on the second loop
Okay sir. I'll try this
Find('+') Finds Last value of Record and FIND('-') Finds First value Of the Record...:=)
IF ItemRec.FIND('+') THEN
MESSAGE(TEXT004, ItemRec."No.", ItemRec.Description, ItemRec."Unit Price")
ELSE
MESSAGE(TEXT001);