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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically Set Option Buttons

Status
Not open for further replies.

ChaosFlyer

Programmer
Jul 15, 1999
1
0
0
US
I (my employer) would like to automatically set two Optiotion Buttons based on a value of 1 or 2 in a database field.<br>
How would I put this in code?<br>
Where would it go?<br>
This is my first solo project, and I would greatly appreciate the help.<br>

 
If you are only storing an positive integer value (eg. 1 or 2) against a field you could do this:<br>
On the form place a frame where you want the option buttons to go. Inside the frame create a crontrol array (Controls that have the same name and are differentiated by an index) of the option buttons. Ensure that you set the indexes that match the data field's max and min values. A good idea would be to start at 0.<br>
When you parse the record from the recordset, just use the value of the field in the recordset as the index to the option control array and then sets its value to TRUE.<br>
eg.<br>
Control array of optArray option buttons.<br>
rs = recordset coming from database.<br>
optArray(rs("FieldNameThatHasTheValue")).Value=TRUE<br>
<br>
To put the data back you would need to iterate the control array and check which index has its value = true and set that index number in the database.<br>
<br>
Good Luck<br>
Nate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top