Results 1 to 12 of 12
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, UK, Berkshire, England
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Catching events on a form (A97/SR2)

    Current situation:
    I have a Preview button on a form and there are certain criteria which need to be true before the user can actually do the preview, e.g. only one check box ticked. I've got a function which returns True/False to check this, but ...
    Option 1. I can test those criteria using the function when they click on the Preview button and either carry out the process, or display a warning message box.
    I don't think this is good GUI practice
    Option 2 Disable the button and only enable when the criteria are true. This means I have to go through the form and add a test to every control which may affect the validity of the criteria check. Ok, maybe, but this does seem prone to possible bugs.

    Is there an easier way to do this check <img src=/S/question.gif border=0 alt=question width=15 height=15>
    I sort of think it's something to do with the events, maybe the WithEvents function. but not sure how to progress <img src=/S/help.gif border=0 alt=help width=23 height=15>

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

    Re: Catching events on a form (A97/SR2)

    I don't think that there is one solution that will fit all situations.

    If the validity check depends on just a few controls, I would choose option 2. You can write a single function to check the criteria and enable/disable the Preview button, and call that from the AfterUpdate event of the relevant controls.

    If the validity check involves a lot of controls, I'd go with option 1. I don't think it's a severe violation of good GUI design.

    In your example (only one check box must be checked), I would use an option group (a frame with radio buttons) instead of check boxes. In an option group, only one radio button can be selected, so you don't have to write code for that.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, UK, Berkshire, England
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Catching events on a form (A97/SR2)

    Thanks for response
    Shame <img src=/S/frown.gif border=0 alt=frown width=15 height=15> it would have been nice if it was possible
    I think I'll go with option 2, I've got the function, so I'll just add to all

    Nah, I'd looked at an option group, but in some cases there are multiple choices, so I had to stick with check boxes

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Catching events on a form (A97/SR2)

    You could sum the values of all the fields. A box that is checked will have a value of -1, and will be 0 if cleared. If the sum is -1, then only 1 box is checked; if it is 0, then no boxes checked, if anything else, the more than 1 box checked.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

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

    Re: Catching events on a form (A97/SR2)

    Option 1 is perfectly normal and acceptable GUI practice and is less tricky than enabling the preview button at the appropriate time. If you have a large number of controls to be checked, you don't want to check them every time one is updated. The logical place to call a validation is from the Click event of the preview button.
    Charlotte

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, UK, Berkshire, England
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Catching events on a form (A97/SR2)

    Thanks for the responses Mark and Charlotte
    - maybe I'm been too much of a perfectionist <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    - it'd just be nice to somehow have the control monitor the state change of the other controls

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

    Re: Catching events on a form (A97/SR2)

    It can be done using withevents, but it is not trivial code, so I would avoid it unless you're really familiar with WithEvents and class automation.
    Charlotte

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, UK, Berkshire, England
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Catching events on a form (A97/SR2)

    I'm not, but would like to learn <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    If you reckon it can be done, I'd welcome any pointers to info on the topic that I can read
    - I've got copies of Access Developers Handbook at work, so a read through them may be in order

  9. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Catching events on a form (A97/SR2)

    I'm 100% with Charlotte on this one, the users soon get used to filling in all the required prompts, and it centres & simplifies the coding.
    Just my <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15> worth.
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  10. #10
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, UK, Berkshire, England
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Catching events on a form (A97/SR2)

    Yeah, I know they do, but it'd just be nice to have the Preview button do the work, rather than have to add the work to every other control. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Seriously, if there was a way to do this, as Charlotte mentioned using WIthEvents, I'd be interesting in trying it out. We have a complete range of users, and some really do need leading around by the nose.
    Our support people would love me if I could reduce any of the stupid calls, so a means to manage the user, even the simple disable of buttons, would be a step in that direction, but the hassle of adding the check to every control means it's back to the check on the Preview, unless this WithEvents offers a better way (all be it more complcated).
    I know this is purist talk, but why have a button enabled when it's not going to do anything apart from tell you not to press it <img src=/S/exclamation.gif border=0 alt=exclamation width=7 height=22>

  11. #11
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Catching events on a form (A97/SR2)

    As you say it's purist talk, but then I gather you want the challenge !! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  12. #12
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, UK, Berkshire, England
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Catching events on a form (A97/SR2)

    Maybe <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    but at least it'd be interesting coding, the reports I'm working on currently are not <img src=/S/frown.gif border=0 alt=frown width=15 height=15>

Posting Permissions

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