New Form In Same Position of Closed Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gumdealer328
    New Member
    • Feb 2008
    • 9

    New Form In Same Position of Closed Form

    I make a second form pop-up and hide the original form by pressing my Next button. How do I make the next form(s) that pop-up appear in the same coordinates as the original? This will make it look like the form is just reloaded in the same spot with new info on it. Any help is greatly appreciated! Thanks in advance!
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Have you worked on TOP and Left property of the form ?

    Comment

    • creative1
      Contributor
      • Sep 2007
      • 274

      #3
      Its very easy to do that.
      First of all note the height; width properties of your first form; and set top and left properties of that form to make it appear whereever you like.
      Now take control of you rsecond form and set all properties (width, height,top,left ) same as they were for first form. It will do the desired job.
      good luck

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        If both of your Forms are of same size, then
        Simply set this property in Property Sheet of both the forms:
        StartUpPosition =2 - CenterScreen

        Automatically, both will be Popped up in the Same Position..

        REgards
        Veena

        Comment

        • gumdealer328
          New Member
          • Feb 2008
          • 9

          #5
          thanks! i got it to work! now the only other problem is why doesn't the application exit when I click the "X" in the upper right corner of the second form?

          Comment

          • MarkTingson
            New Member
            • Nov 2007
            • 40

            #6
            Originally posted by gumdealer328
            thanks! i got it to work! now the only other problem is why doesn't the application exit when I click the "X" in the upper right corner of the second form?
            try this:
            Public Sub UnloadAll()
            Dim oFrm As Form
            For Each oFrm In Forms
            Unload oFrm
            Next
            Set oFrm = nothing
            End Sub
            put this line of code in your queryunload of Form1:
            Call UnloadAll

            Comment

            • lotus18
              Contributor
              • Nov 2007
              • 865

              #7
              Originally posted by gumdealer328
              thanks! i got it to work! now the only other problem is why doesn't the application exit when I click the "X" in the upper right corner of the second form?
              It is something like the first form is in active. If you want to terminte your application by clicking the close button of the 2nd form, you can simply add

              [CODE=vb]Private Sub Form_Unload(Can cel As Integer)
              End
              End Sub
              [/CODE]

              Rey Sean

              Comment

              • gumdealer328
                New Member
                • Feb 2008
                • 9

                #8
                where do i add this code?

                Comment

                • lotus18
                  Contributor
                  • Nov 2007
                  • 865

                  #9
                  Just add 'End' at the Unload Event of the 2nd form ; )

                  Comment

                  • gumdealer328
                    New Member
                    • Feb 2008
                    • 9

                    #10
                    there isn't an unload event for the 2nd form :(

                    Comment

                    • lotus18
                      Contributor
                      • Nov 2007
                      • 865

                      #11
                      Originally posted by gumdealer328
                      there isn't an unload event for the 2nd form :(
                      Really? .

                      Comment

                      • Killer42
                        Recognized Expert Expert
                        • Oct 2006
                        • 8429

                        #12
                        If you mean the Unload event isn't triggered, then presumably you aren't unloading it, which is the whole problem. When your application won't go away, it usually means you have left one or more forms loaded. This is lazy programming, and the sort of thing which wastes resources.

                        You should ensure all forms are unloaded (not just hidden) when you're finished with them. And remember that referring to any of their properties will probably cause them to be loaded again, even if you don't show them.

                        Comment

                        Working...