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 June 20th, 2006, 04:16 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to anukagni Send a message via Yahoo to anukagni
Default Opening Using Option Button


 hi friends,

  It is Possibel to Open an from or a Report by selecting in Option Button.. i.e. For eg

 Two Names Total Report and User Customize Report. Total report is for Opening the Total Report View and User Customize Report is user can customezies the report by what data they desire.

 I want to use an Option Button as for Total Report and user Customize report and command button to executed the function..as when i select the total report then the total report view will get the data and when i chose the user customize report then the customize report from should open..

  is it possible for me to get the data like that ..pls give me an solution



bye
------------------------
pap...
 
Old June 20th, 2006, 07:14 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I use option groups to save values to tables, but I am not sure where you would get the selection value if you wanted to pass it to a command button. Can you use a button for the total report, and then some controls for the user to modify the report as they need to on the same form?


mmcdonal
 
Old June 20th, 2006, 11:54 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the On Click event for the command button, use the following code to take options from an Option Group:

    Select Case [Forms]![frmMainMenu]![OptionGroupName]
        Case 1
            Call Function1()
        Case 2
            Call Function2()
    End Select

Put the code for Function1, Function2, etc. (have as many as you want, can also use parameters if the code is similar between options) in a module called Program Functions.

 
Old June 20th, 2006, 11:55 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

Well, the option button would give you either a 1 or 2 depending on which option you chose. On the option group's After Update event, you can say something like (I'm using fake names for stuff).

Dim strReport as String

If Me.grpMyOptionGroupName = 1 Then
    strReport = "rptTotal"
Else
    strReport = "rptUserCustomize"
End If

DoCmd.OpenReport strReport, acPreview


However, if you want to open the report that the option group is ALREADY sitting on, it won't open unless you pick the other one then come back. That's a pain. In that case, I would not put anything on the option group's After Update event. I would put a button next to it and then put that code on the button's On Click event. So you'd pick an option or leave it where it's sitting, then click the nearby button.



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old June 21st, 2006, 01:34 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to anukagni Send a message via Yahoo to anukagni
Default

hi,

  kindler wat do u mean of creating an program function if , chosse function like that ..plz give me an idea and clarify my doubt...


bye
------------------------
pap...
 
Old June 21st, 2006, 12:27 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Alt-F11 to open VBA
In Project window (top right pane by default)
-Right click on database name
-Click Insert->Module
-New window opens by default

In that window enter as many subroutines or functions as you need. You probably don't need functions for what you are trying to do, the code would look something like this in the On Click event for the command button.

    Select Case [Forms]![frmMainMenu]![OptionGroupName]
        Case 1
            CoCmd.OpenReport "rptTotal", acPreview
        Case 2
            DoCmd.OpenForm "frmCustomizeReport"
    End Select


 
Old June 22nd, 2006, 01:36 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to anukagni Send a message via Yahoo to anukagni
Default

kind,

  I understand plz explain me what is the relation between the case and the option group.. becaz how can it works with option group..plz don't get hot ..plz plz explain..

bye
------------------------
pap...
 
Old June 22nd, 2006, 01:51 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi Pap,

I am about to logoff for the night, but hopefully this can lead you in the right direction.

In an option group, you would assign each radio button a value, lets say 1, 2 and 3 for example. You can now do a Select Case on the value of the option group, and your Case statements would be executed, depending on which radio button was selected.

Hope that helps.

Mike

Mike
EchoVue.com
 
Old June 23rd, 2006, 04:02 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to anukagni Send a message via Yahoo to anukagni
Default

give me an example wat u said above...plz


bye
------------------------
pap...
 
Old June 23rd, 2006, 07:10 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

What you would do is create the option group using the wizard. This will allow you to create labels for each option, and assign numeric values to each option selection, generally 1, 2, 3.

Once you have done this, create a button, and for the button's On Click event, use SerranoG's code to take a value from the Option Group. Based on the value, you select the report you want to run.

You may want to change the code slightly like this:

Dim sReport As String
Dim sForm As String

sReport = "rptYourReportName"
sForm = "frmYourCustomizeReportFormName"

If Me.grpMyOptionGroupName = 1 Then
    DoCmd.OpenReport sReport
Else
    DoCmd.OpenForm sForm
End If

This way, if they want the basic report, they make that selection and open the report. If they want to customize the report, they make that selection from the option group and open the customize report for, which then has your customization controls and a button to open the customized report.

This is all kind of the long way around since you can have a report button on the first form, then customization controls on the same form with a button to open the customized report. But space may be at a premium and a second form is needed?

Does this help?


mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
make option button = bold ff12 Excel VBA 1 March 25th, 2007 11:07 PM
Option Button help mohiddin52 Access 2 September 2nd, 2005 11:05 AM
Option Button & Macro jvanhalderen Excel VBA 2 November 28th, 2004 04:09 PM
How to pass option button array? John Pennington Classic ASP Professional 2 March 8th, 2004 04:41 PM
How do I pass a option button array John Pennington Beginning VB 6 1 March 5th, 2004 03:18 PM





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