Open a Form Relative to another Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JamesHalko
    New Member
    • May 2015
    • 21

    Open a Form Relative to another Form

    I am trying to open a form relative to the main menu. I want the top left corners to align. I have this code in the On Load for the opening form.
    Code:
    DoCmd.MoveSize Forms!MainMenu.Form.WindowLeft, Forms!MainMenu.Form.WindowTop
    Thanks for the help!
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Do you get an error with this?

    Comment

    • JamesHalko
      New Member
      • May 2015
      • 21

      #3
      No error, the form just opens in the center of the screen rather than where I want.

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        Try placing it in the On Open event and try the following code:
        Code:
        With Forms!MainMenu
            DoCmd.MoveSize .WindowLeft, .WindowTop
        End With

        Comment

        • JamesHalko
          New Member
          • May 2015
          • 21

          #5
          Hmm still seems to just open in the center. Do I have to turn on or off some properties?

          Comment

          • Seth Schrock
            Recognized Expert Specialist
            • Dec 2010
            • 2965

            #6
            There is an Auto Center and Auto Resize property. You might try playing with those.

            Comment

            • JamesHalko
              New Member
              • May 2015
              • 21

              #7
              Okay So I have
              Auto Center = No
              Auto Resize = Yes
              My code currently is as follows:
              Code:
              Private Sub Form_Open(Cancel As Integer)
              On Error Resume Next
              Me!Submain.Form.RecordSource = "SELECT * FROM qrypbtinformation WHERE FALSE"
              With Forms!MainMenu
                  DoCmd.MoveSize .WindowLeft, .WindowTop
              End With
              End Sub
              Now it aligns to the top left of the Access window so just under the ribbon and just to the right of the navigation pane instead of the MainMenu

              Comment

              • Seth Schrock
                Recognized Expert Specialist
                • Dec 2010
                • 2965

                #8
                I looked it up to see how I had done it. I have my Auto Center and Auto Resize both set to No. In the On Load event (it probably would work in the On Open event as well), I have
                Code:
                Me.Form.Move Left:=txtProcessorLeft, Top:=txtProcessorTop, Width:=10200, Height:=4000
                The width and height parameters are optional, so you can remove those. txtProcessorTop and txtProcessorLef t are global variables and would be replaced with the values from MainMenu. So try this:
                Code:
                With Forms!MainMenu
                    Me.Form.Move Left:=.WindowLeft, Top:=.WindowTop
                End With

                Comment

                • JamesHalko
                  New Member
                  • May 2015
                  • 21

                  #9
                  That did the trick!!! Thank you so much for your help, I really appreciate it.

                  Comment

                  • Seth Schrock
                    Recognized Expert Specialist
                    • Dec 2010
                    • 2965

                    #10
                    Good! Glad I could help.

                    Comment

                    Working...