PC Review


Reply
Thread Tools Rate Thread

Option Group Auto Open

 
 
Jani
Guest
Posts: n/a
 
      16th Sep 2009
For an option group, is there a way to have it automatically open a form when
a selection is made rather than linking the options to a macro and then
having the macro on a command button? The form has an option group with
several form choices and I would like when the selection of the form is made,
that the form would automatically open rather than having to click a command
button. Thanks in advance for your help, as always! Jani
 
Reply With Quote
 
 
 
 
Klatuu
Guest
Posts: n/a
 
      16th Sep 2009
Not a problem.
If I understand correctly, you want to open different forms based on the
selection in the option group.

You need to use VBA in the After Update event of the option group. Then use
a Select Case statement to identify which form to open and open it. Here is
an Example:

Private Sub MyOption_AfterUpdate()
Dim strFormName as String

Select Case Me.MyOption
Case 1
strFormName = "frmWidgets"
Case 2
strFormName = "frmStuff"
Case 3
strFormName = "frmThings"
End Case

Docmd.OpenForm strFormName
End Dub
--
Dave Hargis, Microsoft Access MVP


"Jani" wrote:

> For an option group, is there a way to have it automatically open a form when
> a selection is made rather than linking the options to a macro and then
> having the macro on a command button? The form has an option group with
> several form choices and I would like when the selection of the form is made,
> that the form would automatically open rather than having to click a command
> button. Thanks in advance for your help, as always! Jani

 
Reply With Quote
 
 
 
 
Jani
Guest
Posts: n/a
 
      16th Sep 2009
Thanks for the super quick response. I'm getting a compile, syntax error,
though, and End Case is highlighted.

"Klatuu" wrote:

> Not a problem.
> If I understand correctly, you want to open different forms based on the
> selection in the option group.
>
> You need to use VBA in the After Update event of the option group. Then use
> a Select Case statement to identify which form to open and open it. Here is
> an Example:
>
> Private Sub MyOption_AfterUpdate()
> Dim strFormName as String
>
> Select Case Me.MyOption
> Case 1
> strFormName = "frmWidgets"
> Case 2
> strFormName = "frmStuff"
> Case 3
> strFormName = "frmThings"
> End Case
>
> Docmd.OpenForm strFormName
> End Dub
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Jani" wrote:
>
> > For an option group, is there a way to have it automatically open a form when
> > a selection is made rather than linking the options to a macro and then
> > having the macro on a command button? The form has an option group with
> > several form choices and I would like when the selection of the form is made,
> > that the form would automatically open rather than having to click a command
> > button. Thanks in advance for your help, as always! Jani

 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      16th Sep 2009
For the record, there is nothing that a macro can do that VBA can't do, and
VBA will always do it better (assuming you know how to tell it to). If you
have any intention of doing serious work with Access, you would do well to
forget about using macros.

Happy coding

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



"Jani" wrote:

> For an option group, is there a way to have it automatically open a form when
> a selection is made rather than linking the options to a macro and then
> having the macro on a command button? The form has an option group with
> several form choices and I would like when the selection of the form is made,
> that the form would automatically open rather than having to click a command
> button. Thanks in advance for your help, as always! Jani

 
Reply With Quote
 
Jani
Guest
Posts: n/a
 
      16th Sep 2009
I changed Case to Select and it's working perfectly. Thank you!

"Jani" wrote:

> Thanks for the super quick response. I'm getting a compile, syntax error,
> though, and End Case is highlighted.
>
> "Klatuu" wrote:
>
> > Not a problem.
> > If I understand correctly, you want to open different forms based on the
> > selection in the option group.
> >
> > You need to use VBA in the After Update event of the option group. Then use
> > a Select Case statement to identify which form to open and open it. Here is
> > an Example:
> >
> > Private Sub MyOption_AfterUpdate()
> > Dim strFormName as String
> >
> > Select Case Me.MyOption
> > Case 1
> > strFormName = "frmWidgets"
> > Case 2
> > strFormName = "frmStuff"
> > Case 3
> > strFormName = "frmThings"
> > End Case
> >
> > Docmd.OpenForm strFormName
> > End Dub
> > --
> > Dave Hargis, Microsoft Access MVP
> >
> >
> > "Jani" wrote:
> >
> > > For an option group, is there a way to have it automatically open a form when
> > > a selection is made rather than linking the options to a macro and then
> > > having the macro on a command button? The form has an option group with
> > > several form choices and I would like when the selection of the form is made,
> > > that the form would automatically open rather than having to click a command
> > > button. Thanks in advance for your help, as always! Jani

 
Reply With Quote
 
Klatuu
Guest
Posts: n/a
 
      16th Sep 2009
My mistake, glad you got it working. End Select is correct.
Just waiting for the coffee to kick in.
--
Dave Hargis, Microsoft Access MVP


"Jani" wrote:

> I changed Case to Select and it's working perfectly. Thank you!
>
> "Jani" wrote:
>
> > Thanks for the super quick response. I'm getting a compile, syntax error,
> > though, and End Case is highlighted.
> >
> > "Klatuu" wrote:
> >
> > > Not a problem.
> > > If I understand correctly, you want to open different forms based on the
> > > selection in the option group.
> > >
> > > You need to use VBA in the After Update event of the option group. Then use
> > > a Select Case statement to identify which form to open and open it. Here is
> > > an Example:
> > >
> > > Private Sub MyOption_AfterUpdate()
> > > Dim strFormName as String
> > >
> > > Select Case Me.MyOption
> > > Case 1
> > > strFormName = "frmWidgets"
> > > Case 2
> > > strFormName = "frmStuff"
> > > Case 3
> > > strFormName = "frmThings"
> > > End Case
> > >
> > > Docmd.OpenForm strFormName
> > > End Dub
> > > --
> > > Dave Hargis, Microsoft Access MVP
> > >
> > >
> > > "Jani" wrote:
> > >
> > > > For an option group, is there a way to have it automatically open a form when
> > > > a selection is made rather than linking the options to a macro and then
> > > > having the macro on a command button? The form has an option group with
> > > > several form choices and I would like when the selection of the form is made,
> > > > that the form would automatically open rather than having to click a command
> > > > button. Thanks in advance for your help, as always! Jani

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Option group auto open - Repost Need Help Soon, Please-thanks! Jani Microsoft Access Form Coding 2 15th Oct 2009 04:31 PM
need help on how to grey out one option button in one group box based on the selection of another option button in another group box George Microsoft Excel Programming 13 11th Mar 2007 03:08 PM
Option Group within another Option Group? =?Utf-8?B?a2xlaXZha2F0?= Microsoft Access Getting Started 1 23rd May 2005 08:57 PM
Option Commands (Option Explicit / Option Base etc) - Scope Alan Microsoft Excel Programming 8 1st Nov 2004 03:22 AM
Option Group option deciding list box contents =?Utf-8?B?Sk1vcnJlbGw=?= Microsoft Access Forms 1 5th May 2004 09:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:43 AM.