option button event

qwertyjjj

Registered User.
Local time
Today, 13:37
Joined
Aug 8, 2006
Messages
262
I have some option buttons in a group.
I'm trying to get them working but can't find the event which fires.

I want to do this:
Dim strSelection As String
strSelection = Trim(opt_AccountCode.Value)
MsgBox (strSelection)

'Select Case strSelection
'Case strYes

'Case strNo

'End Select



Any ideas?
 
You can do it a number of ways:

Code:
Sub Something() 'The event for changing the value of the control will be Controlname_click()

 if me.optControlName.value = True then
   ...Do something
 Else [i]if me.optcontrolname.value = False[/i] 'italicised because it's a binary control, it's true or it isn't
  ... do something else
 end if

'this does the same thing but makes less sense at first view:
  if me.optcontrolname.value = -1 then
    ...Do something   
  else  
    ...Do something else
  end if

Case Select me.optControlname.value
    Case True
      ...Do something
    Case False
      ...do something else
  End Select
End Sub

If you want to you could also declare a Boolean variable and use the control to set the value:

Code:
dim blntest as boolean

blntest = me.optControlname.value

if blntest = True then....
 
Last edited:
The normal event for most controls to check for their value is using the control's AFTER UPDATE event.
 
when I click on the properties box of an option button Click is not one of its events.
It only has gotfocus, etc.
 
when I click on the properties box of an option button Click is not one of its events.
It only has gotfocus, etc.

You don't want the click event of the option button. You should use the After Update event of the OPTION GROUP (not the individual button).
 
Okay, that works.
In code I get an error saying:
You have entered an expression that has no value.

When I run the form, I click the button but it doesn't even bring up the message box or a n error.

Code:
Dim optValue As Integer
optValue = opt_AccountCode.Value
MsgBox (optValue)
 
Can you put in the whole sub up to, and including, the End Sub?
 
Code:
Private Sub optGroup_SortOrder_AfterUpdate()
Dim optValue As Integer
optValue = opt_AccountCode.Value
MsgBox (optValue)

End Sub
 
Slap, sorry I totally missed the bit about it being in a group, all the guff I put before applies to a single option button.

My bad, I'll go sit facing the corner with my dunces hat.
 
What is this: opt_AccountCode and what relation does it have to optGroup_SortOrder
 
Well, there are 5 radio buttons so I gave each of them a name like opt_AccountCode, opt_InvoiceNumber.

Should I be checking the value of the group ?
 

Users who are viewing this thread

Back
Top Bottom