Option Group Auto Open

J

Jani

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
 
K

Klatuu

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
 
J

Jani

Thanks for the super quick response. I'm getting a compile, syntax error,
though, and End Case is highlighted.
 
J

Jack Leach

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

Klatuu

My mistake, glad you got it working. End Select is correct.
Just waiting for the coffee to kick in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top