Prevent multiple instances of a form

GaryDGaryD Member Posts: 66
Is it possible to prevent multiple instances of a form??? The need for this is the following:
We have form A, form B, form C and form D, each with a button that opens form Z. Form Z has a button on it that opens form C. If we have form C open and then use that form to open form Z, the user should be able to click the button on form Z to bring the already opened form C to the front instead of opening up a new instance.

Thanks!

Comments

  • SavatageSavatage Member Posts: 7,142
    how are you getting the form?

    Form.RunModal?
  • matttraxmatttrax Member Posts: 2,309
    Most of me says no, this is not possible :) Then a small part says you can have a table that you insert the userid into when the form open and delete it when you close it. So if you try to open another instance of the form and the userid exists in that table, you don't do it. How you would bring the other form to the front, though, I'm not sure.
  • SavatageSavatage Member Posts: 7,142
    I think teach them to use the Window button :mrgreen:

    Maybe Send Keys with Ctril-f6 but then how do you make it pick a specific form and not run thru all open forms?

    Another thought would be to make 1 form that has the other forms on different tabs so it's all in one place.

    Another thought could be multiple subforms
    http://www.mibuso.com/dlinfo.asp?FileID=290

    Another thought could be like mentioned about another table keeping count.
    http://www.mibuso.com/forum/viewtopic.php?t=2879
  • krikikriki Member, Moderator Posts: 9,115
    matttrax wrote:
    Most of me says no, this is not possible :) Then a small part says you can have a table that you insert the userid into when the form open and delete it when you close it. So if you try to open another instance of the form and the userid exists in that table, you don't do it. How you would bring the other form to the front, though, I'm not sure.
    This is the way I've done it once (not for a customer, but just some test) with some changes:
    -I used a temptable in a singleinstance codeunit. In this table I kept if a form was open or not.
    The problem is that In the OnOpenForm and OnCloseForm, I have to call a function in that singleinstance codeunit to change the status (the same for you with the table). And if a form crashes????? => You have to re-open the company to reset the temptable, otherwise Navision thinks that a form is still open.

    I think that the solution of Savatage are better.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • GaryDGaryD Member Posts: 66
    Thanks for the responses. The problem with opening the form modally is that it may already be open before executing RUNMODAL, in which case it brings up new intance of the form and that is the form that is modal, leaving the original form hanging in the background.

    The other suggestions will take a little investigation on my part since I'm so new at this. But Thanks!
Sign In or Register to comment.