Hello All,
I have a button situated within the sales quote subform.
When I press that, I want to automatically insert a new record into a new table I have created called Quote Approval.
There could be many lines within the sales quote subform and I therefore need to run a loop on the sales line table for this order number.
BUT its not working - HELP!
My code is as follows.......Have I approached this totally wrong?
The LSalesLine.FIND is not working as this is looking at the whole sales line table. I want it to just look at the records for that order number.
One other note: I am carrying over the order number from the Sales Header via a function. This value is held in LOrderNo.
IF NOT CONFIRM('Are you sure you want to send this quote for approval?') THEN
EXIT;
LSalesLine.FIND();
REPEAT
IF Type <> 3 THEN BEGIN
END;
IF LSalesLine."Document No." = LOrderNo THEN
//create incremental number for primary key of table
LrecQuoteApproval.RESET;
IF LrecQuoteApproval.FIND('+') THEN BEGIN
LintNextNumber := LrecQuoteApproval.ApprovalReference + 1;
END ELSE BEGIN
LintNextNumber := 1;
END;
//insert into new table QuoteApproval
GQuoteApproval.RESET;
GQuoteApproval.ApprovalReference := LintNextNumber;
GQuoteApproval."Document No._FK" := LSalesLine."Document No.";
GQuoteApproval."Document Type_FK" := LSalesLine."Document Type";
GQuoteApproval."Line No._FK" := LSalesLine."Line No.";
GQuoteApproval.INSERT;
LSalesLine.NEXT;
END;
UNTIL LSalesLine.NEXT = 0;
0
Comments
I have got it working by changing the line .FIND() to .FIND('-'.
Yes, simple mistake I know....
And I also removed the line LSalesLine.NEXT;
- With this included, I was only getting every other line inserted.
Bye for now