• Detecting a closed Access form (A2K)

    Author
    Topic
    #407140

    I have a subroutine that 1) I want to open a form and 2) execute some code after the form is closed. Access, being incredibly stupid this way, absolutely insists on executing the code before returning from the form, even though the code occurs after the form open statement. How can I force the code to execute only after returning from the form? In essence, my code looks like this:

    docmd.openform “DoSomeWork”
    ExecuteThisSubroutine

    How can I make it wait to run ExecuteThisSubroutine?

    Viewing 0 reply threads
    Author
    Replies
    • #849344

      Access isn’t stupid at all in this respect. In some circumstances, it can be very handy to be able to let code continue after a form has been opened. Access provides a way to do what you want: open the form as a dialog:

      DoCmd.OpenForm FormName:=”DoSomeWork”, WindowMode:=acDialog

      The code following DoCmd.OpenForm will not be executed until after the user has closed the form.

      • #849345

        Thanks for the solution! But I stick to my guns in calling it stupid: when the action is counter-intuitive, and counter to what I need 99.44% of the time, that’s exactly what I call stupid. If others find those features convenient, well, they are more fortunate.

        • #849476

          This isn’t an Access issue, this is the way VBA works.

          hmmn I never realized VBA was supposed to be intuitive. I guess I’ve wasted a lot of time learning how it works instead of using my intuition. drop

          • #849932

            Charlotte,

            I ask this with total respect,

            do you have a “fist of death” bif or don’t you need it because your verbal one is a beauty?

            • #849952

              While Charlotte will usually stand up for herself without any help from others, I feel that I should point out that she has helped literally thousands of posters with her helpful comments. If you cant accept help when it is given, please look elswhere.

            • #849958

              Mate,

              I wasn’t having a go at her, I was admiring her style. She has helped me also.

              Stewart

            • #849959

              Mate,

              I wasn’t having a go at her, I was admiring her style. She has helped me also.

              Stewart

            • #849953

              While Charlotte will usually stand up for herself without any help from others, I feel that I should point out that she has helped literally thousands of posters with her helpful comments. If you cant accept help when it is given, please look elswhere.

          • #849933

            Charlotte,

            I ask this with total respect,

            do you have a “fist of death” bif or don’t you need it because your verbal one is a beauty?

          • #849960

            Charlotte,

            if my comment offended you in any way, you have my sincere appologies. It was a post made out of admiration and amusement.

            Stewart

            • #849965

              It isn’t necessary to apologize or for anyone to defend me. I wasn’t offended. I took your remark as it was intended but I should probably have worded my post less humorously in the first place. Many people get annoyed with Access when they first start out. It is just part of the learning process, and I have no right to disparage anyone else’s frustration with it. If anyone should apologize, it is I, since mods and WMVPs are here to help, not to derail a thread like this.

              VBA is NOT particularly intuitive until you have worked with it for so long that the model is solidly inside your head, and even then it can be annoyingly contrary. Access is even less intuitive because to build a good database requires a lot of understanding of relational design that has nothing to do with VBA, is definitely counter-intuitive at first, and has to be learned bit by bit. Because Access has been marketed as an end user product, newcomers to it often feel frustrated when it is less obvious than a product like Excel or Word, both of which can be simple or complex depending on the skills of the users. However, the spreadsheet model and the document model are, with embellishments, fairly direct translations from paper documents to electronic documents. Access, as a relational database, is nothing of the kind and requires a great deal more effort to use effectively.

            • #850196

              Of course all of you are right about Access. I rarely bother to complain about non-intuitive software anymore, especially when it is produced by Microsoft (kind of like complaining about the bad air here in Houston), but that was one of those rare times when I vented — not against Hans, or Charlotte, or anyone else here, of course. The irony is that I’m not a newbie to Access — I have used it for 10 years now, VBA for all but one of those years. I still find Access clunky at times, although not as clunky as VB itself.

              I would point out that bad software tools are is not the necessary state of things, although what is good or bad is certainly debateable. That we accept the bad without complaint is a certain sign of complacency. I know from my own experience that it is usually easier to go with the flow, but when the flow is upstream against lava filled with boulders, it makes sense to raise some questions.

              Again, I highly value all the advice I get here. You’ve never failed me yet! And I am trying to make my own contribution to other newcomers, as time permits.

            • #850368

              I supposed this is just a matter of opinion, but I reckon that if Access behaved the way you want (in relation to this matter) then this forum would be full of complaints about how non-intuitive Access was.

              Every time you tried to open a form then put a value into a control, or set a property on the form, or set the focus to a particular control, it wouldn’t work!

              I certainly do these things much more often than i want some code to execute when the form closes.

            • #850369

              I supposed this is just a matter of opinion, but I reckon that if Access behaved the way you want (in relation to this matter) then this forum would be full of complaints about how non-intuitive Access was.

              Every time you tried to open a form then put a value into a control, or set a property on the form, or set the focus to a particular control, it wouldn’t work!

              I certainly do these things much more often than i want some code to execute when the form closes.

            • #850197

              Of course all of you are right about Access. I rarely bother to complain about non-intuitive software anymore, especially when it is produced by Microsoft (kind of like complaining about the bad air here in Houston), but that was one of those rare times when I vented — not against Hans, or Charlotte, or anyone else here, of course. The irony is that I’m not a newbie to Access — I have used it for 10 years now, VBA for all but one of those years. I still find Access clunky at times, although not as clunky as VB itself.

              I would point out that bad software tools are is not the necessary state of things, although what is good or bad is certainly debateable. That we accept the bad without complaint is a certain sign of complacency. I know from my own experience that it is usually easier to go with the flow, but when the flow is upstream against lava filled with boulders, it makes sense to raise some questions.

              Again, I highly value all the advice I get here. You’ve never failed me yet! And I am trying to make my own contribution to other newcomers, as time permits.

            • #849966

              It isn’t necessary to apologize or for anyone to defend me. I wasn’t offended. I took your remark as it was intended but I should probably have worded my post less humorously in the first place. Many people get annoyed with Access when they first start out. It is just part of the learning process, and I have no right to disparage anyone else’s frustration with it. If anyone should apologize, it is I, since mods and WMVPs are here to help, not to derail a thread like this.

              VBA is NOT particularly intuitive until you have worked with it for so long that the model is solidly inside your head, and even then it can be annoyingly contrary. Access is even less intuitive because to build a good database requires a lot of understanding of relational design that has nothing to do with VBA, is definitely counter-intuitive at first, and has to be learned bit by bit. Because Access has been marketed as an end user product, newcomers to it often feel frustrated when it is less obvious than a product like Excel or Word, both of which can be simple or complex depending on the skills of the users. However, the spreadsheet model and the document model are, with embellishments, fairly direct translations from paper documents to electronic documents. Access, as a relational database, is nothing of the kind and requires a great deal more effort to use effectively.

          • #849961

            Charlotte,

            if my comment offended you in any way, you have my sincere appologies. It was a post made out of admiration and amusement.

            Stewart

        • #849477

          This isn’t an Access issue, this is the way VBA works.

          hmmn I never realized VBA was supposed to be intuitive. I guess I’ve wasted a lot of time learning how it works instead of using my intuition. drop

    Viewing 0 reply threads
    Reply To: Detecting a closed Access form (A2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: