how to call a form while creating a new record ?

how to call a form while creating a new record ?

ex; In sales order detail if u create new record it will open a new sales order along with a num sequence.

i have a main form ,similarly i want to open a new entry form with a num sequence while clicking the create.

pls help me out.

Override the create method of the form data source

Args args = new Args();

FormRun formRun;

args.name(formstr(YourForm));

formRun = classfactory.formRunClass(args);

formRun.init();

formRun.run();

formRun.detach();