Case Statement Example
Let's go back to our first section, where we had an option group called optGroup. Let's say it has three radio buttons, which have values 1, 2 & 3. You could then code your button as follows:
intGroup = me!optGroup - This passes the value from the option group into a variable called intGroup
Select Case intGroup
msgbox "You chose option 1"
msgbox "You chose option 2"
msgbox "You chose option 3"
msgbox "Please choose an option"
Note that you should use the Case Else statement depending on what values might be passed to the variable you are working on. With an option group, you can set a default value, which means that apart from in the event of an error, it would be impossible for the variable to have a value that wasn't 1, 2 or 3. You could always use Case Else to cover the default option you'd like to choose in the event of an error.