The trouble with CheckBoxes ...

Posted on 2011-10-20
Last Modified: 2012-05-12
... is that if you click on them the checkbox immediately toggles to the reverse value.

I have a Checkbox (BBReq) which allows the user to specify whether a particular Participant attending an Event requires Bed & Breakfast accomodation.

If the value in BBReq is True then data can be entered into the BBCost, BBCharge, BBExtras, BBQtyGuests, BBQtyNights, BBStartDate, BBEnSuiteReq, BBDisAccReq, BBQtySingle, BBQtyDouble, BBQtyTwin, BBQtyFamily, BBName and BBRef (i.e. quite a lot of data).

If the value in BBReq is False then none of these fields are available (locked) and are all empty of data.

So far no problem.

If BBReq on Form load is False and it is clicked then it goes to True and I unlock all the BB fields - agian this is no problem.

Here is the problem

If BBReq on form load is True and it is clicked then it goes to False and I want to cancel all the values in the BB fields ... BUT I want to warn the user that the data is about to be cleared and give them a chance to change their mind.  I use a VBOKCancel msgbox to do this.

It all works but if the operation is cancelled the BBReq checkbox remains unchecked and the user may then worry that the Cancel has not worked (despite all the other fields having not been cleared of data).

Is there any way of resetting the BBReq CheckBox with a tick?
Question by:MikeDTE
    LVL 10

    Accepted Solution

    Just set it to true if they decide to cancel. I'm assuming you check for which action they choose OK or Cancel. So if they cancel, just use ...

    myCheckBox = true

    LVL 47

    Expert Comment

    by:Dale Fye (Access MVP)
    What code are you using?

    It should look something like:

    Private sub chk_BBReq_Click

        if me.chk_BBReq.oldValue = True and me.chk_BBReq.value = False then

            if msgbox("Are you sure", vbOkCancel) = vbCancel then
                me.txt_BBCost = NULL
                me.txt_BBCost.Locked = true
                me.txt_BBRef = NULL
                me.txt_BBRef.locked = true
            end if


    LVL 47

    Expert Comment

    by:Dale Fye (Access MVP)
    forgot the End Sub in previous post.

    However, if I were doing this, I think I would have all of the Bed & Breakfast info in a separate table and use a subform, linked by event and person to the main table.

    If the the user checks BBReq or BBReq is already checked, then make the subform visible .  If there is no current record, add one.

    If the user unchecks BBReq, then confirm thats what they want to do, then delete the associated record from the B&B table and hide the subform.
    LVL 47

    Expert Comment

    by:Dale Fye (Access MVP)
    Or you might even do this with a popup form, rather than a subform.

    Author Comment

    OK the answer was a simple as

    Me.BBreq = True

    basically as suggested by ALaRiva - the points go to ALaRiva - thanks v much.

    I swear I tried this first (before my initial post) but it didn't work!!!

    I did try the .undo option but it didn't work.

    I am too far into this form to split it away to a subform and seperating the B&B data into it's own table is just too much work for someting as simple as a tick in a box.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now