• Catching events on a form (A97/SR2)

    Author
    Topic
    #373202

    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 question
    I sort of think it’s something to do with the events, maybe the WithEvents function. but not sure how to progress help

    Viewing 2 reply threads
    Author
    Replies
    • #599020

      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.

      • #599021

        Thanks for response
        Shame frown 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

    • #599031

      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.

    • #599043

      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.

      • #599050

        Thanks for the responses Mark and Charlotte
        – maybe I’m been too much of a perfectionist smile
        – it’d just be nice to somehow have the control monitor the state change of the other controls

        • #599056

          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.

          • #599057

            I’m not, but would like to learn smile
            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

      • #599078

        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 2cents worth.
        Pat cheers

        • #599139

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

          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 exclamation

          • #599144

            As you say it’s purist talk, but then I gather you want the challenge !! grin
            Pat cheers

            • #599150

              Maybe smile
              but at least it’d be interesting coding, the reports I’m working on currently are not frown

    Viewing 2 reply threads
    Reply To: Reply #599021 in Catching events on a form (A97/SR2)

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

    Your information:




    Cancel