Hi David, Depending on the number of record sets on
the form this could be different, but assuming a form with a single table…….. Create a variable in the Form Class
declaration such as Boolean lineAdded; Next edit the ACTIVE method on the table
data source you are interested in After the call to Super…. if(!TABLENAME.RecId)
lineAdded = true; A bit of explanation on the above, when
you insert a record on a form Axapta fires data source methods in this order,
Create à Leave à Active, Creates the new record, then leaves the current record,
then sets the new record active. You might be tempted to add the
lineAdded = true to the create method but that will cause problems coming up
when we modify the leave method …. So Next modify the LEAVE method on the
data source, something like this around the super call … if(!lineAdded)
ret = super(); else{
info('click the button');
ret = false; } Return ret; The above will keep them from leaving the
record that has been added, keep in mind if your dealing with multiple data sources
on the form, and the line addition you are watching is on the child data source,
you will need to make the same modification to the parent data source leave
method. We also need to consider what happens when
the user starts to add a line but deletes it…no need to click the
button, in the DELETE method of the concerned data source and
perhaps the parent data source add … lineAdded = false; Lastly you will want to modify the
CANCLOSE method on the form, add code like this before the return… if(lineAdded){
ret = false;
info('click Button'); } Of course, add a button, and make sure
when it is clicked it sets lineAdded = false; That should do it G’luck - From: Hi, YAHOO! GROUPS LINKS
|