Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Buttons 2

Status
Not open for further replies.

leonepaolo

Programmer
May 28, 2001
82
0
0
CA
Hi,

When the user clicks into a text box, I would a certain option button to be selected or check.

Any recommendations would be appreciated.

Thanks in advance,
Paolo
 
Have you tried to set the frame value to the corresponding OptionValue ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
For the TEXT boxes, you have two events that you might consider using. They are the ON ENTER and ON EXIT events.

Example:

On a form, you have an OPTION FRAME (buttons, checkboxes, whatever) named OPTION_BOX and it has two choices.

OPTION_BOX
+-----------------------+
| O Box 1 was selected | <-- Option Value = 1
| O Box 2 was selected | <-- Option Value = 2
+-----------------------+

Then you have three (3) Text boxes named BOX1, BOX2 and BOX3

+-----------+
| | This is BOX1
+-----------+

+-----------+
| | This is BOX2
+-----------+

+-----------+
| | This is BOX3
+-----------+

The following VBA code will set the value of the OPTION_BOX to 1 if the user clicks in the Text Box named BOX1. It will set the value of OPTION_BOX to 2 when the user clicks in the Text Box named BOX2.

Just for cleanup, and to to illustrate the ON EXIT property, if the user clicks in Text Box 3 (or anywhere else for that matter), the value of OPTION_BOX resorts to null. (You might want to have a default or otherwise control for this).

' HERE IS THE VBA CODE FOR THE ABOVE EXAMPLE

Private Sub BOX1_Enter()
Me.OPTION_BOX = 1
End Sub
Private Sub BOX1_Exit(Cancel As Integer)
Me.OPTION_BOX = Null
End Sub
Private Sub BOX2_Enter()
Me.OPTION_BOX = 2
End Sub
Private Sub BOX2_Exit(Cancel As Integer)
Me.OPTION_BOX = Null
End Sub

I hope this helps.

Alan J. Volkert
Fleet Services
GE Commercial Finance Capital Solutions
(World's longest company title)
Eden Prairie, MN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top