SetFocus on an option button

G

Guest

Hi,
I have a form with three option buttons. Each of them has a specific
procedure that runs when the user clicks it. These procedures activate or
disable some fields according to some specifications.
Now when the user navigates from record to record, I want the fields to
display as they were when they were set in the first place, hidden, disabled,
etc. For that, I use the form's current event. But when I try to set the
focus to some option button, I get an error message saying that this can't be
done.
To prevent this error and to get the job done, I tried to execute the
procedure that executes when the option button is clicked. It works.
Is that normal?
I use Access 2003, but at the office, they still have Access 2000 and the
form's current event doesn't even fire. Is that a bug in Access 2000 or an
installation problem?
Here is the code I use:
' **********************************
Private Sub Form_Current()
Me.SetFocus
If Me.TypeDeFumeur = 1 Then
Me.optNonFumeurÀVie.SetFocus
ElseIf Me.TypeDeFumeur = 2 Then
Me.optFumeurACessé.SetFocus
ElseIf Me.TypeDeFumeur = 3 Then
Me.optFumeur.SetFocus
End If
End Sub
' **********************************
Thanks.
 
D

Duane Hookom

If the option buttons are part of an option group, you can set the focus to
the group, not the button. You can also set the value of the group to select
a specfic button.
 
G

Guest

Hi Duane,
My idea was to enable/disable some textboxes according to the value of the
group where my option buttons are placed. I changed the code to that and it
works.
' *******************************
Private Sub Form_Current()
Me.SetFocus
If Me.TypeDeFumeur = 1 Then
optNonFumeurÀVie_GotFocus
ElseIf Me.TypeDeFumeur = 2 Then
optFumeurACessé_GotFocus
ElseIf Me.TypeDeFumeur = 3 Then
optFumeur_GotFocus
End If
End Sub
' *******************************
Instead of trying to set the focus to the option button, I execute the
procedure the is executed when the option button is clicked.
I guess that is a reasonable solution?
Thank you for your reply. It helps.
 
G

Guest

Hi again Duane,
I tried to simply set the focus to the group and it works well.
' **********************************
Private Sub Form_Current()
Me.SetFocus
Me.grpTypeDeFumeur.SetFocus
End Sub
' **********************************
I thought I let the community know.
KISS, they say.
Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top