Results 1 to 6 of 6

Thread: stop form from being opened again if opened

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    Georgia
    Posts
    337

    stop form from being opened again if opened

    I know that this works for the complete app to stop a duplicate app from running

    If App.PrevInstance = True Then
    End
    End If

    How can I modify this code to not allow a form from being opened more than once at the same time.

    Thanks for your help

  2. #2
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Form does not open twice unless you wish to open.
    Simply saying form1.show twice will not open the form1 twice.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    Georgia
    Posts
    337
    well it is a bit more complicated than that in my app.

    I have a full screen mainform from that I have solved the user from minimizing it and opening another by the code shown in the original post.

    However the main form allows the user to open a claim "record" and if he trys he can open a second claim "record" which actually gets really messed up and intermingled with the first. So I'm trying to prevent the user from opening a second record while the first is still open by not allowing the form containing the record to be opened a second time.

    Hope that makes some sense of my mess.

    Thanks for the help

  4. #4
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    I dont understand exactly but you would loop thru the forms and see if the one yer talking about is open and if it is then dont open another one. heres a function to use.. Put the function in a Bas or in your form

    VB Code:
    1. Function IsFrmOpen(FrmName As String) As Boolean
    2. Dim ofrm As Form
    3. For Each ofrm In Forms
    4.     If ofrm.Name = FrmName Then
    5.         IsFrmOpen = True
    6.         Exit For
    7.         End If
    8. Next ofrm
    9. End Function

    then to use it just go like this..
    VB Code:
    1. If IsFrmOpen("Form2") Then MsgBox "It's open"
    Last edited by Arc; Jan 28th, 2003 at 05:33 PM.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    Georgia
    Posts
    337
    Thanks for the help Arc

    I will give that a try.

    Thanks again for the help

  6. #6
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    If you really do not want user to open the 2nd record while the 1st is open, you should be opening the form in modal mode.

    form1.show vbmodal is the syntax. That will prevent the re-opening of form cause it will force the user to close the 1st one before opening 2nd.

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