473,378 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

use option buttons to change control source

I would like to use a set of three option buttons on a form so that depending on which one is selected a text box is bound to one of three corresponding fields. I'm not really sure what the code is to change the control source. Any help would be great.

Ty
Aug 7 '07 #1
3 14404
puppydogbuddy
1,923 Expert 1GB
I would like to use a set of three option buttons on a form so that depending on which one is selected a text box is bound to one of three corresponding fields. I'm not really sure what the code is to change the control source. Any help would be great.

Ty
Place your option buttons in an option group frame. The option group allows only one button at a time to be selected, and will track and perform actions based on the selection. Sample code is illustrated below. Replace X with the actual name of your option group, and replace the other generic object names I used for illustrative purposes.:
Expand|Select|Wrap|Line Numbers
  1. Private Sub optgrpX_AfterUpdate()
  2.  
  3. 'load appropriate control source for textbox1
  4. Select Case Me![optgrpX]
  5.     Case 1
  6.          Me!txtbox1.ControlSource  = field1
  7.     Case 2
  8.          Me!txtbox1.ControlSource  = field2
  9.     Case 3
  10.          Me!txtbox1.ControlSource  = field3
  11. End Select
Aug 7 '07 #2
Thanks for the help, I just started working with access and am still having a little trouble. I'm using access 2007, so I'm now creating an option group by using the option group tool. I enter my three differnt options in the wizard, then after it's created I clicked on the option group frame and in the afterupdate event I created the new event procedure and entered that code. Is this right, or should I be doing it a different way, because I still haven't got it to work yet. Thanks.

Ty
Aug 7 '07 #3
puppydogbuddy
1,923 Expert 1GB
Thanks for the help, I just started working with access and am still having a little trouble. I'm using access 2007, so I'm now creating an option group by using the option group tool. I enter my three differnt options in the wizard, then after it's created I clicked on the option group frame and in the afterupdate event I created the new event procedure and entered that code. Is this right, or should I be doing it a different way, because I still haven't got it to work yet. Thanks.

Ty
Sounds like you did it ok, but the values and names of the option groups and buttons have to be assigned also by invoking the property sheet. Example for illustration purposes...you must use the actual names of your objects.

option buttons:
>>>Names: optbtn1, optbtn2, optbtn3
>>> option values: 1, 2, and 3 respectively

option group frame:
>>>>>name:optgrpInquiries
>>>>>default value: 0 if you don't want any of the buttons selected by default, or the value of the button you want as the default

in the code I gave you previously, Case 1 would correspond to selecting optbtn1 with a value of 1.
Aug 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Edward | last post by:
I have a data entry form that allows the user to navigate around entirely using the keyboard. However, it contains various option button controls which are in the tab order. Whenever they are...
0
by: Robert | last post by:
Stephen, I think I figured out the problem. I was able to get Check Boxes and Option Buttons to work on my form by TURNING OFF RECORD SELECTORS on the form. Not sure why this would make a...
5
by: tsnyder | last post by:
I need to have an option button that allows editing to a field only when it is checked.
3
by: Dave Smithz | last post by:
Hi there, Summary: I'm looking for a good open source, Windows Change control program. What are people using for there PHP projects? Is there a clear leader for this? Can programs like MS...
0
by: sselvi | last post by:
Hi! I am using the visual basic applications in powerpoint to create a program which will enable the user to enter a mulitiple choice question and options for that question. For eg. if the user...
5
by: Killer42 | last post by:
Hi all. I'm coming from a VB6 background so this is just confusing me a little. I have a form where the user can select one of a number of years to search. The selection doesn't relate directly to...
15
beacon
by: beacon | last post by:
Hi everybody, Using Access 2003. I'm trying to dynamically set the record source for the current form and set the control source for a text box to input data to one of three tables. I have a...
2
beacon
by: beacon | last post by:
Hi everybody, I have a form that has a combo box that asks the user to select the program they work on. Once the user selects the program, a SQL statement populates the row source for 4 staff...
7
by: tomric | last post by:
I have two forms, one with two command buttons, the other is a testing critera input form. Both cmd bottons open the same form. The first opens it to input test criteria, and is attached to a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.