Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detecting a closed Access form (A2K)

    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?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Detecting a closed Access form (A2K)

    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.

  3. #3
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting a closed Access form (A2K)

    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.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Detecting a closed Access form (A2K)

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

    <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15> 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. <img src=/S/drop.gif border=0 alt=drop width=23 height=23>
    Charlotte

  5. #5
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Emerald Beach, New South Wales, Australia
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting a closed Access form (A2K)

    Charlotte,

    I ask this with total respect,

    do you have a "fist of death" <img src=/S/bif.gif border=0 alt=bif width=70 height=28> or don't you need it because your verbal one is a beauty?

  6. #6
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Blacktown, Sydney, New South Wales, Australia
    Posts
    175
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Detecting a closed Access form (A2K)

    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.

  7. #7
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Emerald Beach, New South Wales, Australia
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting a closed Access form (A2K)

    Mate,

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

    Stewart

  8. #8
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Emerald Beach, New South Wales, Australia
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting a closed Access form (A2K)

    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

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Detecting a closed Access form (A2K)

    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.
    Charlotte

  10. #10
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting a closed Access form (A2K)

    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.

  11. #11
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Detecting a closed Access form (A2K)

    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.
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •