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!

Using option buttons to move between forms

Status
Not open for further replies.

annamika

Technical User
Feb 7, 2004
2
0
0
US
I am a novice user attempting to collect some research data using VB. My respondents have to select between two different options on each of several questions (each question appears separately on a different screen). Is there any way I can get the next screen to come up on the clicking of an option button rather than insert a command button and have my respondents click the command button to move to the next screen. Since I have multiple screens, one click saved would help tremendously.

Alternatively, is there a way by which I can use command buttons instead of option buttons? When I tried this, the only problem was that one of the command buttons is invariably set to default value true which is not optimal.

Thanks!
 
You have to put the option buttons in an Option group.(By default the group name comes as Frame#)

Set the value of the group to null on Form Open. This removes the default value

Best of luck
 
Thank you. However, grouping the option buttons does not allow me to eliminate the command button to move to the next screen. If I try grouping command buttons instead of option buttons, I am unable to remove the default value on one of them.

Thanks again.
 
Why don't you use Afterupdate Event of the option group

I hope I am getting you right

Best of luck

 
Hi Annamika,
On the OnClick event for your option buttons, why not set then to GoToPage1 or DoCmd.OpenForm "YourFormName" and so forth. I think that should get you where you want to be. However, you still have that ONE click either way it goes. Be it an OptionButton or CommandButton, you still have to CLICK once. Ever consider a Tabbed Form? Tell me how it goes.

Bud
 
You can make a option group with option buttons set values and navigate for you simply.

Example:
Create a new form. On it:
Create two buttons - name them: T1 T2 - in an option group - name it: Opt001
Set the Option value of T1 to 1
Set the Option Value of T2 to 2
Create a text box - Name it Txt1 elsewhere on the form.
Create a tab control with two pages. Name it Tab1.
Name the two pages Pg1, and Pg2 respectively
Select each Tab page respectively and put a different lable on each page.
Create a table; Tbl1 with a field: OptGrpVal set that field's data type to "number"
Make Tbl1 the form's RecordSource.
Select Opt001 and make it's ControlSource OptGrpVal

In the option Group's after update event add this code to make stuff happen.

Private Sub Opt001_AfterUpdate()

Select Case Opt001

Case 1
T1.FontSize = 12
T2.FontSize = 8
Pg1.SetFocus

Case 2
T1.FontSize = 8
T2.FontSize = 12
Pg2.SetFocus
End Select

Txt1 = Opt001

End Sub

Click on the buttons and you will see a great navagational tool that should address your needs.

To keep everything under your control, select the whole tab control by clicking in it's extreme upper right corner so that the Properties dialog box shows" Tab Control: Tab1" at it's top. Select the format tab. Select "Style" and choose "None" from the dropdown list. Your tabs will dissapear so that all tab navagation is driven through your code and the users enter data and navigate per your plan.

The textbox shows that what you get when you use an option group is the value of the group as an entirety. Click on different option buttons with different values, and the value of the whole group changes.

I suspect you will quickly discover how to proceed further, but do ask any questions that occur!

Best....

Charlie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top