Problems setting focus on a field, locked into field...

G

Guest

I have a form that uses combo boxes to allow the user to select a customer.
Sometimes they want to have the combo box show the information by ID#,
sometimes by name.

I created radio button to select the method. If they select the radio
button for ID, it enables the ID# combo box, disables the Name combo box and
makes the Name box invisible.

If they press the button for Name, it switches what is visible and enabled.

My problem - I figured it would be nice if upon entering the form, you were
directly in the combo box field (default set at ID#), or, upon selecting one
or the other button, it takes you to the field right away.

SetFocus, SelectObject work to get me there, but then you can't go back and
select the other radio button option. I lets me press regular buttons, but
not the radio button selectors.

So.... any insight you can lend would be great....
-------------------------------------
Private Sub Form_Load()
Me.Combo4.Visible = False
Me.Combo4.Enabled = False
Me.Combo7.Visible = True
Me.Combo7.Enabled = True
Me.Combo7.SetFocus
End Sub
--------------------------------------
Private Sub Option13_GotFocus()
Me.Combo4.Visible = True
Me.Combo4.Enabled = True
Me.Combo7.Visible = False
Me.Combo7.Enabled = False
Me.Combo4.SetFocus
End Sub
---------------------------------------
Private Sub Option15_GotFocus()
Me.Combo4.Visible = False
Me.Combo4.Enabled = False
Me.Combo7.Visible = True
Me.Combo7.Enabled = True
Me.Combo7.SetFocus
End Sub
 
G

Guest

Never mind... I've been testing the option selector (hence only having the
choices of "GotFocus" as events, which should have clued me in) instead of
the frame....
 
M

Marshall Barton

aemAndy said:
I have a form that uses combo boxes to allow the user to select a customer.
Sometimes they want to have the combo box show the information by ID#,
sometimes by name.

I created radio button to select the method. If they select the radio
button for ID, it enables the ID# combo box, disables the Name combo box and
makes the Name box invisible.

If they press the button for Name, it switches what is visible and enabled.

My problem - I figured it would be nice if upon entering the form, you were
directly in the combo box field (default set at ID#), or, upon selecting one
or the other button, it takes you to the field right away.

SetFocus, SelectObject work to get me there, but then you can't go back and
select the other radio button option. I lets me press regular buttons, but
not the radio button selectors.

So.... any insight you can lend would be great....
-------------------------------------
Private Sub Form_Load()
Me.Combo4.Visible = False
Me.Combo4.Enabled = False
Me.Combo7.Visible = True
Me.Combo7.Enabled = True
Me.Combo7.SetFocus
End Sub
--------------------------------------
Private Sub Option13_GotFocus()
Me.Combo4.Visible = True
Me.Combo4.Enabled = True
Me.Combo7.Visible = False
Me.Combo7.Enabled = False
Me.Combo4.SetFocus
End Sub
---------------------------------------
Private Sub Option15_GotFocus()
Me.Combo4.Visible = False
Me.Combo4.Enabled = False
Me.Combo7.Visible = True
Me.Combo7.Enabled = True
Me.Combo7.SetFocus
End Sub


Use the AfterUpdate event instead of GotFocus.

If the radio buttons are not in an option group, use each
radio button's AfterUpdate event.

If the buttons are in an option group, then you need to use
the group frame's AfterUpdate event instead of the
individual button's event. In this case the code would be
more like:

Me.Combo4.Visible = (Me.optionframe = x)
Me.Combo4.Enabled = (Me.optionframe = x)
Me.Combo7.Visible = (Me.optionframe <> x)
Me.Combo7.Enabled = (Me.optionframe <> x)
Me.Combo4.SetFocus

Where x is option13's OptionValue
 

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