Proper way to use option control groups (1 Viewer)

mamradzelvy

Member
Local time
Today, 16:31
Joined
Apr 14, 2020
Messages
145
Hello,
I'm struggling to find a good guide on option control groups, radio buttons and check boxes mainly.
I'm trying to make a month selector for a query i use for export to excel, but on my own i just wasn't able to put it together.
Is there a guide somewhere, or do you have any tips on how to make this happen?
I'm confused as in how to refere to the option group and get its values, the 1,2,3 etc. to represent a sql syntax instead.
 

cheekybuddha

AWF VIP
Local time
Today, 15:31
Joined
Jul 21, 2014
Messages
2,238
Hi,

Use the wizard to add your option group to your form.

Then the trick to getting the value is that the value is stored in the frame object around the radio buttons.

Once added, select the frame on your form in design view. It will likely be called something like 'fra1'. You might wish to name it something more meaningful.

Then, in its OnChange event property choose '[Event Procedure]', and click the little button with the ellispis (three dots) nest to it.

You will be taken to the code editor:
Code:
Private Sub fra1_Change()

  Select Case Me.fra1
  Case 0
'   Do something when value is 0
  Case 1
'   Do something when value is 1
  Case 2
'   Do something when value is 2
  Case 3
'   Do something when value is 3
  Case Else
'   Etc ...
  End Select

End Sub

hth,

d
 

isladogs

MVP / VIP
Local time
Today, 15:31
Joined
Jan 14, 2017
Messages
18,186
Before you go down that line, why not just use a combo box or a listbox for a month selector.
Having 12 radio buttons or similar for each month is fairly wasteful of screen space
 

Users who are viewing this thread

Top Bottom