Results 1 to 16 of 16

Thread: Multiple Forms Opening When Not Desired

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    8

    Multiple Forms Opening When Not Desired

    Okay, so here's my problem. I have a group of buttons all with different labels. I want to have each of these specific buttons open up the same form, but my problem is when I write the code of form1.show it pops open twenty or so different windows. How to I make one button open just one window? Thanks for the help!

  2. #2
    Addicted Member EilaDoll's Avatar
    Join Date
    Dec 2011
    Posts
    147

    Re: Multiple Forms Opening When Not Desired

    Which form are you putting this on and can you post the code itself?
    http://www.vbforums.com/image.php?type=sigpic&userid=142423&dateline=1337150730

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Multiple Forms Opening When Not Desired

    We're not mind readers nor are any of us sitting in your lap (at least I hope not) so we can't see what you're seeing. Which includes the code... there could be a number of reasons for this, but we won't know which one it is until you post your code.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    8

    Re: Multiple Forms Opening When Not Desired

    You'll have to bare with me. This is all new to me. So I do appreciate the help though.


    Public Class TrnTimeTable

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub trn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trn1.Click

    frmContact.Visible = True


    End Sub
    End Class

    That's my code. And I'm using the Windows Form App

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    8

    Re: Multiple Forms Opening When Not Desired

    Public Class frmContact

    Private Sub frmContact_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim oForm As frmContact
    oForm = New frmContact()
    oForm.Show()
    oForm = Nothing
    End Sub
    End Class

    And that's the code I'm using for my second form I'm attempting to open within my button

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Multiple Forms Opening When Not Desired

    unfortunately that's not what you're doing... you're actually using the timer to open the forms.

    The code that you have in the Load event is what should be behind the click event of the button, with a small change.

    Code:
    Public Class TrnTimeTable
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim oForm As frmContact
      oForm = New frmContact()
      oForm.Show()
    End Sub
    That's it... that's all you really need.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    8

    Re: Multiple Forms Opening When Not Desired

    Yep, that fixed it. Thanks a lot, I really appreciate it! Now I can get to figuring out how to make buttons disappear when you hit a submit button.

  8. #8
    Addicted Member EilaDoll's Avatar
    Join Date
    Dec 2011
    Posts
    147

    Re: Multiple Forms Opening When Not Desired

    Should be easy

    Button2.hide()
    or
    Button2.Show()
    http://www.vbforums.com/image.php?type=sigpic&userid=142423&dateline=1337150730

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Multiple Forms Opening When Not Desired

    .Visible property.... as a design note though... typical users hate things showing & hiding themselves... it's something of an aberrant behavior. Enabling/Disabling will make better sense to them... then again... it all depends on the context.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    8

    Re: Multiple Forms Opening When Not Desired

    Not sure it'll be that easy, as I have 28 buttons that all open the same contact form, unless I made 28 duplicates of the same contact form, which I guess I could do, just seems like kinda a hassle.

  11. #11
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Multiple Forms Opening When Not Desired

    woah.... 1) why so many buttons... and 2) why so many buttons that all do basically the same thing?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    8

    Re: Multiple Forms Opening When Not Desired

    It's a calendar que type deal, and they all gotta open the same basic template, which I could I guess make the same template and just have 28 different ones. And the buttons are separate times for people to schedule things at work. No one else is really interested in fixing our broken system, so I'm taking it upon myself to try and make it work. You've been a huge help in this, so I do appreciate it.

  13. #13
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Multiple Forms Opening When Not Desired

    Have you considered using a calendar rather than so many buttons?

  14. #14

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    8

    Re: Multiple Forms Opening When Not Desired

    I wasn't aware that was even an option....but we have a calendar currently and it's kinda screwy, so I'll probably stick with what I have currently. I've figured out how to make the cancel buttons and all that work. Just not to make the time button be disabled via clicking the submit button.

  15. #15
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Multiple Forms Opening When Not Desired

    Button.Enabled=false

  16. #16

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    8

    Re: Multiple Forms Opening When Not Desired

    Thanks Data. I actually found a couple work arounds with Form.Button.Show and Button.Hide I appreciate everyones help though!

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