Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 8th, 2004, 12:33 AM
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vnadig
Default Option group

Hi guys and gals,

I am trying to program an option group in access. I want some help. I want the code for selecting each button on the form based on the value of the option group. I have 5 options in the group and when i select a particular button on the same form. so please help:)

vish

vishy
 
Old September 8th, 2004, 07:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Can you please describe in more detail what you mean?

If you have an option group, say five items, why would you have five buttons on the form tied to the choices? You'd only need ONE button. The button would react differently depending on which of the five options is chosen.

So I guess I need more info to answer your question.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old September 8th, 2004, 10:23 AM
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vnadig
Default

Hey Greg,

Thanks for your reply. Here is the scenerio
Option group has 5 items (say cars, trucks, planes and trains) and i want to open the specific form by activating that particular button (Cars option >>> the cars form button will become active; trucks option>>> will make the truck button active (selected) while keeps the other button inactive and so on....

thanks
vish

vishy
 
Old September 8th, 2004, 10:26 AM
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vnadig
Default

Quote:
quote:Originally posted by SerranoG
 Can you please describe in more detail what you mean?

If you have an option group, say five items, why would you have five buttons on the form tied to the choices? You'd only need ONE button. The button would react differently depending on which of the five options is chosen.

So I guess I need more info to answer your question.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 Hey Greg,

Thanks for your reply. Here is the scenerio
Option group has 5 items (say cars, trucks, planes and trains) and i want to open the specific form by activating that particular button (Cars option >>> the cars form button will become active; trucks option>>> will make the truck button active (selected) while keeps the other button inactive and so on....

thanks
vish

vishy


vishy
 
Old September 8th, 2004, 12:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

OK, that's very clear. First, you don't need five buttons. You only need one. What you do, is that depending on which option you use, the ON CLICK event code of the button will differentiate which form to open.

Read this on-line to see the code formatting better. It may be more confusing in a non-formatted e-mail message. I'm making up the names of your option group and button. Replace my names with your real names.

Code:
Public Sub cmdMyButton_Click()

    On Error GoTo Err_cmdMyButton_Click

    Dim strFormName As String
  
    Select Case grpMyOptionGroup
        Case 1
            strFormName = "frmMyFirstForm"
        Case 2
            strFormName = "frmMySecondForm"
        Case 3
            strFormName = "frmMyThirdForm"
        Case 4
            strFormName = "frmMyFourthForm"
        Case 5
            strFormName = "frmMyFifthForm"
    End Select
 
    DoCmd.OpenForm strFormName
 
Exit_cmdMyButton_Click:
    Exit Sub
 
Err_cmdMyButton_Click:
    MsgBox Err.Description, vbExclamation, "Error " & Err.Number
    Resume Exit_cmdMyButton_Click
     
End Sub
 
Old September 8th, 2004, 12:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Oops! I went back to my post and corrected mistyping. I changed strDocName to strFormName to be consistent.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old September 8th, 2004, 02:53 PM
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vnadig
Default

Hey Greg,

thanks for this help. I spent 2 hours yesterday thinking about. I really appreciate... this

thanks again
vish

vishy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Check Boxes/Option buttons/Option Group hewstone999 Access VBA 1 March 14th, 2008 07:25 AM
Option Group Variables (from Form to Module) emanuele.musa VB How-To 1 July 20th, 2007 03:58 PM
Hide Subform Using Option Group martinaccess Access 1 October 3rd, 2004 10:48 AM
How to deselect "Option Group" box? reindeerw Access 6 May 11th, 2004 06:46 AM
Option Group Procedures Mr.Crud Access VBA 7 February 12th, 2004 06:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.