Results 1 to 2 of 2

Thread: form modal

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    103

    form modal

    how can i prevent opening a form when it is already opened?
    ie
    if i press a cmdbutton, it opens a form.
    how can i prevent that the same form is opened again when pressing the cmdbutton again?
    i only want one instance of the form to be open

  2. #2
    Hyperactive Member Bananafish's Avatar
    Join Date
    Jan 2001
    Posts
    394
    If you open the form Modally - then you wont even be able to press the command button
    VB Code:
    1. Dim oForm as New frmX
    2. oForm.ShowDialog()

    However, if you don't want the form to be displayed modally, then you could just set a module level variable whenever the form is opened.

    If you do this though you would need a property in the new form (frmX) that holds the object reference of the parent form, and a property in the parent form that allows the module variable to be reset when the form is closed...

    Have I made sense or just confused?

    VB Code:
    1. Dim oForm as New frmX
    2. mbooFormShowing = True
    3. oForm.ParentForm = Me 'ParentForm defined as a public property of frmX
    4. oForm.Show

    Then in frmX - when it closes/is disposed...

    VB Code:
    1. Me.ParentForm.FormShowing = False 'Property in the parent Form that updates mbooFormShowing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width