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

 

-Preston

 

 

 

 

 

 

 

 


From: Axapta-Knowledge-Village@yahoogroups.com [mailto:Axapta-Knowledge-Village@yahoogroups.com] On Behalf Of David VanEchaute
Sent: Monday, August 08, 2005 10:37 AM
To: 'Axapta-Knowledge-Village@yahoogroups.com'
Subject: [Axapta-Knowledge-Village] Button on Form mandatory

 

Hi,

Could someone please explain how it could be made that a button on a form is
made to be mandatory when a line(s) is added to the form or at minimum an
info message appear if the user doesn't "click" on a button after a line(s)
have been added?

Thanks,

David





Sharing the knowledge on Axapta.



YAHOO! GROUPS LINKS




Reply via email to