Show/Hide a Dialog Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OldBirdman
    Contributor
    • Mar 2007
    • 675

    Show/Hide a Dialog Form

    I want a form that is Modal, PopUp, and Dialog, but that is hidden most of the time so that the fields are available to the code of my other forms.
    Modal means that only the form can have control, until it is closed or hidden, I hope.
    PopUp means that the form remains on top of other forms, I hope.
    Dialog means that the code stops until the form is closed or hidden, then the code continues, I hope.

    The form ("fOptions") properties are Pop Up=Yes, Modal=Yes, and BorderStyle=Dia log.

    I open form with:
    DoCmd.OpenForm "fOptions", acNormal, , , , , acHidden
    or
    DoCmd.OpenForm "fOptions", acNormal, , , , acDialog, acHidden

    When I do Forms!fOptions. Visible = True, the code doesn't wait for the form to be hidden again (not Dialog?).

    How may I achieve this objective?

    Old Birdman

    P.S. Is there a thescriptsforum for dummies?
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Originally posted by OldBirdman
    Old Birdman

    P.S. Is there a thescriptsforum for dummies?
    Like the name and don't worry we take all comers in the question stakes. Just one thing, you have posted this in the Articles section rather than in the forum. I am now moving this question to the Access forum.

    Mary

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32645

      #3
      Originally posted by OldBirdman
      I want a form that is Modal, PopUp, and Dialog, but that is hidden most of the time so that the fields are available to the code of my other forms.
      Modal means that only the form can have control, until it is closed or hidden, I hope.
      PopUp means that the form remains on top of other forms, I hope.
      Dialog means that the code stops until the form is closed or hidden, then the code continues, I hope.

      The form ("fOptions") properties are Pop Up=Yes, Modal=Yes, and BorderStyle=Dia log.

      I open form with:
      DoCmd.OpenForm "fOptions", acNormal, , , , , acHidden
      or
      DoCmd.OpenForm "fOptions", acNormal, , , , acDialog, acHidden

      When I do Forms!fOptions. Visible = True, the code doesn't wait for the form to be hidden again (not Dialog?).

      How may I achieve this objective?

      Old Birdman

      P.S. Is there a thescriptsforum for dummies?
      Interesting question. You don't sound like a dummy to me.
      Unfortunately, if I'm right, you can only have a form work modally if it is visible.
      I'm not sure exactly what allows code to continue (close or hide), but if it's Hide, then I wouldn't expect a Show to suspend the code again. If truth be told, I wouldn't expect the Hide to resume the code execution either, but that's only my guesswork.

      Code resumption can be arranged (not straightforward ly :() by using the OnTimer event to check the status of the form. It means redesigning the structure of the code a little I'm afraid.

      Comment

      • OldBirdman
        Contributor
        • Mar 2007
        • 675

        #4
        I am Dummy as to using this site. I posted to "Articles Section" in error, Thanks Mary for moving post.
        I have tried to search Access Section, but all searches seem to be of entire site, and must read through too many hits, when I don't even understand most of the stuff outside Access.
        I am afraid to turn off computer after post, as I don't know how to find MY Thread again.

        My question is apparently not understood.
        1. If I originally open my Options Form with "DoCmd.Open Form "fOptions", acNormal, , , , , acHidden" and with the form properties as PopUp=True; Modal=True; BorderStyle=Dia log then the form is open and accessable for such tests as: "If Forms!fOptions. chkConfirmDelet e then ... Msgbox ..... End If"
        2. If my command button "Change Options" uses the code "Forms.fOptions .Visible = True", the form shows, and is modal. I cannot use the primary form until I close fOptions, but the code continues to the end. No problem if I am changing choices for future events, but if I am changing the filter for the current display, the code runs with the original filter, because the computer is faster than my typing.
        3. Selecting the command button "Change Options" again will achieve the desired result, as the code runs to completion with the prior open of the form.

        I am not trying to run a modal/dialog form while hidden, only when visible. I could assign all items on the form to Global Variables, but this seems awkward, and Access continually loses all values for Global Variables if ANY ERROR occurs. This means that whenever I debug a program, and an error occurs, I may loose the values of ALL global variables. This makes debugging very slow and lots of clicks.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32645

          #5
          Originally posted by OldBirdman
          I am Dummy as to using this site. I posted to "Articles Section" in error, Thanks Mary for moving post.
          I have tried to search Access Section, but all searches seem to be of entire site, and must read through too many hits, when I don't even understand most of the stuff outside Access.
          I am afraid to turn off computer after post, as I don't know how to find MY Thread again.
          Let's deal with the easy first then.
          Searching within a particular forum:
          This is a relatively new feature and is still having teething troubles. When the option is there, there will be a selection of the current forum or the whole site. You're just unlucky enough to come in at a time of great flux.
          Finding posts again:
          Wherever you are in the site, there should be a menu type area at the top-right. It will show something like :
          Code:
          0 PMs | Control Panel | Buddy List | Help | Site Map
          If you click on Control Panel it will show you a list of ALL the threads you're subscribed to. This will include, but not be limited to, all the threads that you have initiated.

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Originally posted by OldBirdman
            I am Dummy as to using this site. I posted to "Articles Section" in error, Thanks Mary for moving post.
            I have tried to search Access Section, but all searches seem to be of entire site, and must read through too many hits, when I don't even understand most of the stuff outside Access.
            I am afraid to turn off computer after post, as I don't know how to find MY Thread again.

            My question is apparently not understood.
            1. If I originally open my Options Form with "DoCmd.Open Form "fOptions", acNormal, , , , , acHidden" and with the form properties as PopUp=True; Modal=True; BorderStyle=Dia log then the form is open and accessable for such tests as: "If Forms!fOptions. chkConfirmDelet e then ... Msgbox ..... End If"
            2. If my command button "Change Options" uses the code "Forms.fOptions .Visible = True", the form shows, and is modal. I cannot use the primary form until I close fOptions, but the code continues to the end. No problem if I am changing choices for future events, but if I am changing the filter for the current display, the code runs with the original filter, because the computer is faster than my typing.
            3. Selecting the command button "Change Options" again will achieve the desired result, as the code runs to completion with the prior open of the form.

            I am not trying to run a modal/dialog form while hidden, only when visible. I could assign all items on the form to Global Variables, but this seems awkward, and Access continually loses all values for Global Variables if ANY ERROR occurs. This means that whenever I debug a program, and an error occurs, I may loose the values of ALL global variables. This makes debugging very slow and lots of clicks.
            Try putting a DoEvents command in the appropriate place. This will tell the processor to complete all previous commands before moving forward.

            Comment

            • OldBirdman
              Contributor
              • Mar 2007
              • 675

              #7
              Help "DoEvents" is an example, I cannot find a description of this function. Therefore, I cannot find where might be an appropriate place. Can you elaborate?

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32645

                #8
                Originally posted by OldBirdman
                Help "DoEvents" is an example, I cannot find a description of this function. Therefore, I cannot find where might be an appropriate place. Can you elaborate?
                Originally posted by Help
                DoEvents Function


                Yields execution so that the operating system can process other events.

                Syntax

                DoEvents( )

                Remarks

                The DoEvents function returns an Integer representing the number of open forms in stand-alone versions of Visual Basic, such as Visual Basic, Professional Edition. DoEvents returns zero in all other applications.

                DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent.

                DoEvents is most useful for simple things like allowing a user to cancel a process after it has started, for example a search for a file. For long-running processes, yielding the processor is better accomplished by using a Timer or delegating the task to an ActiveX EXE component.. In the latter case, the task can continue completely independent of your application, and the operating system takes case of multitasking and time slicing.

                Caution Any time you temporarily yield the processor within an event procedure, make sure the procedure is not executed again from a different part of your code before the first call returns; this could cause unpredictable results. In addition, do not use DoEvents if other applications could possibly interact with your procedure in unforeseen ways during the time you have yielded control.
                To get help on this, open the Immediate pane in the VBA window (Ctrl-G), type in DoEvents then press F1. This will invoke context-sensitive help for whatever is under the cursor.

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32645

                  #9
                  Getting back to the second part of the question (Post #4) though, I would say that the code that succeeds the opening of the modal form, and which depends on the form being closed again (or hidden) should be placed in a publicly accessible function which can be called by the code which hides the form. This is, in effect, the logically correct place for it to be in object-oriented programming (IMHO).
                  It is code that depends on the form being closed, therefore it should be triggered (somehow) by the closing of the form.

                  Comment

                  • OldBirdman
                    Contributor
                    • Mar 2007
                    • 675

                    #10
                    OK, I did that. DoEvents gives the value 0, which according to Help means that nothing is running. As to how it applies to my problem, I am uncertain.

                    Comment

                    • OldBirdman
                      Contributor
                      • Mar 2007
                      • 675

                      #11
                      To solve my problem I am uncertain. I have an answer, but I do not understand. I very much appreciate all the effort being expended to resolve my issues, but I still am not certain I understand. I want a form visible to my code, and when visible to my users, modal. I still don't think I understand how to achieve this.

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32645

                        #12
                        Which answer are you referring to?

                        Comment

                        • OldBirdman
                          Contributor
                          • Mar 2007
                          • 675

                          #13
                          Help "DoEvents" is an example, I cannot find a description of this function. Therefore, I cannot find where might be an appropriate place. Can you elaborate?

                          Comment

                          • MMcCarthy
                            Recognized Expert MVP
                            • Aug 2006
                            • 14387

                            #14
                            Originally posted by OldBirdman
                            Help "DoEvents" is an example, I cannot find a description of this function. Therefore, I cannot find where might be an appropriate place. Can you elaborate?
                            Can you post the actual code you are using as I think there is some confusion.

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32645

                              #15
                              Originally posted by OldBirdman
                              Help "DoEvents" is an example, I cannot find a description of this function. Therefore, I cannot find where might be an appropriate place. Can you elaborate?
                              I thought I'd explained that quite fully in post #8. Did you see that one?

                              Comment

                              Working...