The Access Wizard Newsletter Tips Tricks and Traps for Access Users and Developers
July 2008

Option Groups -- An Easy Way to Allow Selections

Summer in New England is a glorious time of year! There's nothing like going to the local ice cream stand and enjoying chocolate chip cookie dough ice cream on a sugar cone.

At our local place all the flavors are listed on a board so you can make your selection before getting to the window. Seeing all the selections at once makes it easy to understand the universe of choices.

Think of how inconvenient and time consuming the ice cream selection process would be if you had to review flavors one at a time and then make your selection. What if the flavors were listed one at a time on one of those scrolling feeds that you see on the bottom of the television screen when you're watching CNN? No doubt you'd have to review the list several times and that would not be fun. We're talking ice cream in July and it's supposed to be fun!

Similarly, when designing forms you might be tempted to go to the familiar combo box when you want to present a list of just a few things. Sometimes the better alternative is a different type of control, an option group box, and that's what we'll consider this month.

In this Issue
  • Tip of the Month - Turn on Form/Report Wizards
  • Option Group-The Basics
  • Creating Your First Option Group
  • Running the Form and Niceties
  • Conclusion and a Look Ahead
  • Trap of the Month- Beware of Ampersands in Labels

  • Option Group-The Basics

    The most important characteristic about an option group is that it can present a list of options to a user and allow him/her to choose one and only one choice. The neat thing about option groups is that when a user clicks on one item, the other items are automatically deselected. This makes it very simple to speed things up when you need a user to make a single choice from a predefined list. The easiest way to learn about how to make an option group is to actually go through the process.

    Creating Your First Option Group

    Start with a blank form in design view and then click on the toolbox icon. In the toolbox there is a small box with an XYZ.

    Go ahead and click that box. Provided you have Wizards turned on (they're on by default--- if you need to turn the Wizards on check out this month's tip) you'll see the dialog box below:

    On the screen, enter the labels that you would like to appear as choices in the option group.

    I'm going to use Summer Camp Departments as my example. Once you enter your label names in the order you want them listed, click Next and you'll get the dialog box below.

    As you can see, Access has assigned values to each label. These values are what are selected behind the scenes when the user makes a choice in the option group. By default Access will use numbers as the values stored. You could change these to something else (e.g. the label names), however I recommend you use numbers since they are easier to manipulate and more efficient to work with.

    When you click next again, you'll get the dialog box below, which invites you to designate a default value.

    Although you may skip assigning a default value, I recommend that choose a default since the use of the option box implies that something will be chosen. If you have a situation where the user may want to deliberately not choose one of the choices, it makes sense to include an option such as All or None. That way, the option group will always return a value you can work with.

    When you hit Next again, you'll see the screen below which will allow you to make some style choices. At this point you may want to play around a bit to see what appeals to you and your users.

    Click next again and you'll get an option that allows you to put a title on your option group. Finally hit Finish and your form will be similar to the picture below.

    Running the Form and Niceties

    At this point you're ready to try out your form. Click the form view button (or press F5) and you'll see something like picture below. I've dressed things up a bit by adding a title to the form, creating an OK button, and toggling some of the options in the form. Click on the various options and you'll see that the form deselects one option when you choose another one.

    Conclusion and a Look Ahead

    Now that you know the basics of an option group, it becomes very simple to show users all their choices on a compact screen and help them make one selection from a set of possible options. At this point we haven't covered how we deal with the user selections - that will be the subject of the upcoming August Wizard: learning how to manipulate the user selection and other uses of option groups.

    Trap of the Month- Beware of Ampersands in Labels
    Acess Traps

    When you put an ampersand (&) in a label, Access interprets this as a call to underline the next character and turn it into a Hot Key. For instance, if you type Arts & Crafts in a label, you'll find that Access will put an underscore character between Arts & Crafts rather than an ampersand.

    This is really annoying! In order to compensate for this, simply double the ampersand. When Access sees the dual ampersands, it will correctly show a single ampersand in your label.

    Tip of the Month - Turn on Form/Report Wizards

    When building a form or report you'll find that Access does a lot of work automatically for you. This happens because by default the Form/Report Control Wizard is turned on. You can tell it's turned on because when you add controls, e.g. an option box as in this month's article, Access will start asking you questions about how the control should behave.

    If you find that you don't get the expected questions, you may have inadvertently turned the Form/Report Wizard off.

    To turn it back on, open a form or report in design view, click on View | Tool box. You'll see the control toolbox as below

    Click on the wand with the magic dust coming off of it and that will toggle the wizards on and off.

    Quick Links...

    If you can't see all the Pictures Click Here for Online Version

    Custom Software Home

    Access Wizard Archives

    Our Services

    Join our mailing list!

    Forward email

    Safe Unsubscribe
    This email was sent to jim@custom-software.biz, by jim@custom-software.biz

    Custom Software | Copyright Custom Software All Rights Reserved | Westford | MA | 01886