work on 2 pop up forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Neruda
    New Member
    • Mar 2017
    • 72

    work on 2 pop up forms

    If u have 2 pop up forms opened, a large one and a smaller one, is there any way they can be both worked on and the smaller one always stay on top? Just like when u work in a form in design view in access, the property sheet is always on top and u can work on both. thanks
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Neruda,
    Must they be separate forms, or can one be a sub-form of the other?

    Comment

    • Neruda
      New Member
      • Mar 2017
      • 72

      #3
      they are 2 separate pop up forms, the smaller popup opens with a button within a subform of the large form

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        Just a guess here, but maybe you could something with the OnFocus of the bigger form. When that form gains the focus you fire an event in the subform that puts the focus on an object in the subform and then then the same event in the main form puts the focus back on itself. So if you switch to another program, both forms might go to the background but when you come back to the main form you will make both forms on top any other open windows.

        Jim

        Comment

        • isladogs
          Recognized Expert Moderator Contributor
          • Jul 2007
          • 483

          #5
          Sorry but if both forms are popups, there shouldn't be a problem

          If the smaller popup is opened by clicking a button on the larger popup, it should always be on top.

          If the second form was already open when the first form is opened, it will go to the back of the 'z-order'. However clicking the button on the first form will restore it to the top.

          Very basic example attached.

          Of course, clicking on the larger form will restore focus to that and hide the smaller form if located in the same place. But you can click the button again ...
          OR just move the smaller form to one side.
          OR change the larger form so it isn't a popup!
          Attached Files
          Last edited by isladogs; Dec 3 '20, 08:35 PM. Reason: More info...

          Comment

          • Neruda
            New Member
            • Mar 2017
            • 72

            #6
            how about hide or close the yellow form when it goes to the back?

            Comment

            • isladogs
              Recognized Expert Moderator Contributor
              • Jul 2007
              • 483

              #7
              You can certainly hide or close the smaller (yellow) form when it goes to the back, but why bother? It is effectively hidden anyway

              Comment

              • Neruda
                New Member
                • Mar 2017
                • 72

                #8
                I need to close it because I want the formLoad event to run again every time the yellow form is closed, how do you close the form just by focusing on the large form, tried with lost focus event but did not work
                Thanks

                Comment

                • isladogs
                  Recognized Expert Moderator Contributor
                  • Jul 2007
                  • 483

                  #9
                  One simple method is to add code to the Detail_Click event of the large (blue) form which closes the smaller (yellow) form.
                  To show when the yellow form is being reopened, I've added a message to the Form_Load event of that form.

                  Adapt as appropriate to suit your requirements.
                  Attached Files

                  Comment

                  • twinnyfo
                    Recognized Expert Moderator Specialist
                    • Nov 2011
                    • 3664

                    #10
                    Neruda,

                    You can add the code that runs on the OnLoad Event anywhere in your form. There is nothing that says it must be in the OnLoad event.

                    Just make it a public sub/function and refer to it from the other form when you need to:

                    Code:
                    Call Forms![FormName].[Sub/FunctionName]
                    Hope that hepps!

                    Comment

                    • Neruda
                      New Member
                      • Mar 2017
                      • 72

                      #11
                      Thank u for your answers, in the end I have done what u suggested and also added this code to hide the smaller form once it loses focus

                      Code:
                      Private Sub Form_Timer()
                      
                      ' error trap is used to process situations when not a form is clicked outside of the popup form
                      On Error GoTo NotForm:
                            
                          If Me.Name = Screen.ActiveForm.Name Then Exit Sub
                           
                      NotForm:
                          Me.TimerInterval = 0
                          Me.Visible = False
                       
                      End Sub

                      Comment

                      Working...