Subform's Query

N

Nano

I have created a form and a sub form in it. I have radio buttons, now
what I want is that if first radio button is select Form-A opens in
subform and when I select second radio button, Form-B opens in
subform.

I have created a Event_Procedure for After_Update radio buttons like
this:

--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub Radio_AfterUpdate()
On Error GoTo Radio_AfterUpdate_Err

If (Radio = 1) Then
subForm1.SourceObject = FormA

End If
If (Radio = 2) Then
subForm1.SourceObject = FormB
End If


Radio_AfterUpdate_Exit:
Exit Sub

Radio_AfterUpdate_Err:
MsgBox Error$
Resume Radio_AfterUpdate_Exit

End Sub

--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------

But now when I select the any of two buttons, no forms open and the
subform remains null. Kindly help, thanking you in anticipation.

Regards,
Hasnain Raja
 
D

Dale Fye

Nano,

Are these radio buttons in a frame (option group)? In order for radio
buttons to work so that only one can be enabled, you have to put them inside
a frame.

Have you put a breakpoint in your code and looked at the value of "Radio"?
Is Radio the control name of the Radio "frame" I mentioned above? If not,
then this is not going to work.

You might want to prefact subform1 with the "Me", and wrap the name of your
sourceObject in quotes, like:

Me.Subform1.SourceObject = "FormA"

HTH
Dale
 
N

Nano

Nano,

Are these radio buttons in a frame (option group)? In order for radio
buttons to work so that only one can be enabled, you have to put them inside
a frame.

Have you put a breakpoint in your code and looked at the value of "Radio"?
Is Radio the control name of the Radio "frame" I mentioned above? If not,
then this is not going to work.

You might want to prefact subform1 with the "Me", and wrap the name of your
sourceObject in quotes, like:

Me.Subform1.SourceObject = "FormA"



Thanks Dale for replying, yes these radio buttons are in frame and
Radio is the name of the frame which contains these radio buttons. Yes
I have put the break point and the value of Radio is changing
correctly.

But I thikn there is some problem in code open the forms or I am
putting it in wrong event. I am putting it in After_Update event of
button.
 
D

Dale Fye

Nano,

Sorry for the delay in responding. Did you get this working?

Have you tried putting quotes around the name of the form?

Private Sub Radio_AfterUpdate()

On Error GoTo Radio_AfterUpdate_Err

Select Case Radio
Case 1
me.subForm1.SourceObject = "FormA"
Case 2
me.subform1.SourceObject = "FormB"
Case Else
msgbox "Invalid selection
End Select

Radio_AfterUpdate_Exit:
Exit Sub

Radio_AfterUpdate_Err:
MsgBox Error$
Resume Radio_AfterUpdate_Exit

End Sub
 

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