 |
| 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
|
|
|
|

September 8th, 2004, 12:33 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

September 8th, 2004, 07:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
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
|
|

September 8th, 2004, 10:23 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

September 8th, 2004, 10:26 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

September 8th, 2004, 12:00 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
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
|
|

September 8th, 2004, 12:04 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
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
|
|

September 8th, 2004, 02:53 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hey Greg,
thanks for this help. I spent 2 hours yesterday thinking about. I really appreciate... this
thanks again
vish
vishy
|
|
 |