calling form from codeunit

Hey all, i have some trouble with a form: i want to open a form from a codeunit. This form contains some parameter the user can choose. After having choosen the form writes the results into a table and ends. So far so good. My problem: the codeunit opens the form and does the next steps without waiting for the form to be terminated. How can i make the codeunit wait ? thanks in advance STEFAN

Did you try FORM.RUNMODAL?

yes i did. But i only got the message that runmodal can’t be used within a codeunit. I tried it with Form.LOOKUPMODE(TRUE); Form.RUN too, but the result was the same as in the beginning. :frowning:

Should work (what Heinz said) but only if you haven’t made any MODIFY() or INSERT() etc… before that RUNMODAL()… If so you need to put a COMMIT() before the RUNMODAL-line (with all problems that may pose :slight_smile: )…

the COMMIT was the secret. Now it works. many thanks to Heinz and LG

Stefan, if COMMIT was the problem, you should have got this overwhelming, screen-filling error message, right? [:)]

yes Heinz, you’re right. But i interpreted this message as there was no way to start a form within a codeunit and wondered, how (and why) this could be. however, sometimes a little hint helps to solve mountainhigh problems… :wink:

AND ? IF FORM.RUNMODAL(50000, REC) = ACTION::LOOKUPOK THEN …