Dynamic checkbox control array access2k3 form

Posted on 2011-10-28
Last Modified: 2012-05-12
On an access form I want to have a control array of checkbox's that will only allow 1 checkbox from the control array to be selected. The count of checkbox's on the form and the caption's of the checkbox's need to be driven from a query recordset which contains a name and a value.

Depending on which checkbox is selected I will run an event using the value from that checkbox. Below is the query I want to build the checkbox's on the form

SELECT, campaign.status, campaign.campaignID
FROM campaign
WHERE (((ncts_campaign.campaign_type)="O"));

The field would be the caption of the checkbox, the campaign.status would be whether the checkbox was checked or unchecked, the campaign.campaignID would be the value that I would use to relate back to the record in order to update the campaign.status field.

Please help with the VBA needed to make this happen, I have searched online but cant find anything close to what I'm trying to do.
Question by:Dalexan
    LVL 77

    Accepted Solution

    Access does not have control arrays which is possibly why you can't find anything about it.

    I am not about to produce any code for this, but the nearest equivalent would be an Option Group control, set up to use checkboxes.  However use of 'exclusive' check boxes is not really in line with the standards everyone else uses, is it.
    'Radio buttons' is the normal UI to present in such a case.


    Author Comment

    So can anyone help me with the VBA necessary to make this happen with a radio button option group control. I am unfamiliar with this....
    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    <No Points wanted>

    Like Pete I try to shy away form posting solution that too far afield from what is commonly done.
    I have never seen a application that used "Exclusive" checboxes.

    Checkboxes will signify a list of selections.
    Select your uses for this product:
    a. Work
    b. Home
    c. School
    Here checkboxes would be used, because you can select more than one use.

    An example of an Option group would be:
    Select your Shipping method:
    a. UPS
    b. Fed Ex
    c. USPS you can only make one selection...Hence option buttons are commonly used.

    So using exclusive checkboxes would create a counter-intuitive, non-standard user interface.

    If you used option buttons you could use the Option group wizard as Pete stated and be done.

    But hey, you can wait, perhaps an expert will be be willing to take this on...

    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    As far as Control Arrays go, ...they are not available in VBA, though strangely enough, they are in VB6

    In Access you have to "loop" (enumerate) the controls

    Dim ctl as control
    For each ctl in me.controls
        If ctl.Controltype=accheckbox then
            'Do Something
            'Do something else
        end if
    Next ctl

    Author Closing Comment

    Oh well, I will go ahead with figuring out the option group control.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    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!

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

    737 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

    19 Experts available now in Live!

    Get 1:1 Help Now