Option group with command button

raphael99

Registered User.
Local time
Today, 15:13
Joined
Apr 6, 2015
Messages
126
Hi. I'm using option group with value 1 and value 2 with a command button to open two different forms.
This is the code:

Code:
 Private Sub Command9_Click()
Dim strForm As String

Select Case Me.Cornice0
    Case Is = 1
        strForm = "FRMMeseCorrentePrestazioni"                            ' Open contracts form
        DoCmd.OpenForm strForm                           ' Open required form
    Case Is = 2
        strForm = "FRMMesePrecedentePrestazioni"                           ' Open main form
       DoCmd.OpenForm strForm                          ' Open required form
End Select
        
End Sub

I would like to close form's option group once clicked the command button after the opening of the requested value form.
I tried Docmd.close but all I get is the option group no more working
 
I add Docmd.Close here :
Code:
 Private Sub Command9_Click() 

Dim strForm As String  Select Case Me.Cornice0     

Case Is = 1     strForm = "FRMMeseCorrentePrestazioni"     ' Open contracts form         DoCmd.OpenForm strForm                                           ' Open required form   Case Is = 2   strForm = "FRMMesePrecedentePrestazioni"   ' Open main form        DoCmd.OpenForm strForm                    ' Open required form End Select      
 [SIZE=4][B]Docmd.Close[/B][/SIZE] 
End Sub

But not open any form and does not close the option group form
 
Last edited:
not sure abnouit the "is"
I normally do this sort of thing

Code:
 Dim strForm As String

on error goto fail
Select Case Cornice0
Case 1:
strForm = "FRMMeseCorrentePrestazioni" 
Case 2:
strForm = "FRMMesePrecedentePrestazioni" 
End Select

DoCmd.OpenForm strForm ' Open required form
docmd.close acform,"launch form name" 'these argument may be the wrong way round!

exit sub

fail:
mgbox "error opening form " & strform

end sub
 
Last edited:
Thanks Gemma it works. but when I add Docmd.Close, it not close the form. what you suggest?
 

Users who are viewing this thread

Back
Top Bottom