using option group to give focus

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

Hi,

I have 4 fields that hold numeric data. I've created a set of command
buttons to act as a quasi-calculator to write numbers to the 4 respective
text boxes, depending on which option button in an unbound option group has
the current focus.

Im my attempt to use an Option Group to determine which of the 4 text boxes
has the focus -- thus is some code I've been trying:

Private Sub FrameAdmin_AfterUpdate()
If Me!FrameAdmin.OptionValue = "1" Then
Me!cboNFLID.SetFocus
ElseIf Me!FrameAdmin.OptionValue = "2" Then
Me!txtYear.SetFocus
ElseIf Me!FrameAdmin.OptionValue = "3" Then
Me!txtRnd.SetFocus
ElseIf Me!FrameAdmin.OptionValue = "4" Then
Me!txtPck.SetFocus
ElseIf Me!FrameAdmin.OptionValue = "5" Then
Me!txtOverall.SetFocus
End If
End Sub

This fails -- I get a run time error 438 object doesn't support this method
or property -- which must mean that I am referencing int eh OprionValue
property incorrectly.

What I am doing wrong> How do I reference the OptionValue property in code?

thanks
 
-----Original Message-----
Hi,

I have 4 fields that hold numeric data. I've created a set of command
buttons to act as a quasi-calculator to write numbers to the 4 respective
text boxes, depending on which option button in an unbound option group has
the current focus.

Im my attempt to use an Option Group to determine which of the 4 text boxes
has the focus -- thus is some code I've been trying:

Private Sub FrameAdmin_AfterUpdate()
If Me!FrameAdmin.OptionValue = "1" Then
Me!cboNFLID.SetFocus
ElseIf Me!FrameAdmin.OptionValue = "2" Then
Me!txtYear.SetFocus
ElseIf Me!FrameAdmin.OptionValue = "3" Then
Me!txtRnd.SetFocus
ElseIf Me!FrameAdmin.OptionValue = "4" Then
Me!txtPck.SetFocus
ElseIf Me!FrameAdmin.OptionValue = "5" Then
Me!txtOverall.SetFocus
End If
End Sub

This fails -- I get a run time error 438 object doesn't support this method
or property -- which must mean that I am referencing int eh OprionValue
property incorrectly.

See help on the OptionValue property; that is for another
purpose.

You want to use the Value property, which being the
default does not need to be referred to explicitly. A
Select Case statement will also make your code more
understandable. Try:

Private Sub FrameAdmin_AfterUpdate()

Select Case Me!FrameAdmin
' You could also use:
' Select Case Me!FrameAdmin.Value
' But Value is the default property of a control

Case 1:
Me!cboNFLID.SetFocus
Case 2:
Me!txtYear.SetFocus
Case 3:
Me!txtRnd.SetFocus
Case 4:
Me!txtPck.SetFocus
Case 5:
Me!txtOverall.SetFocus
End Select

End Sub

HTH
Kevin Sprinkel
 
Back
Top