Visible Subreports

  • Thread starter Thread starter gakersm
  • Start date Start date
G

gakersm

Guest
I know there are a lot of threads regarding visible subreports but I can't seem to make use of the coding.

I have a form with an option group that brings up 1 of 2 subforms. I managed to figure out how to code that correctly from this forum. Now I need to accomplish the same thing with a report/subreports generated from the form. However, I can't seem to transfer the coding from the form over to the report and get it to work. I am a complete beginner with VB so I'm sure that I have syntax problems. Could someone please help me with this?

Here is what I have tried...

Private Sub Meeting_Agenda_RPT_OnOpen(Cancel As Integer)
If Meeting_Type = 1 Then
Me.Mtg_Subreport.Visible = True
Else: Me.Mtg_Subreport.Visible = False
End If
If Meeting_Type = 2 Then
Me.CC_Subreport.Visible = True
Else: Me.CC_Subreport.Visible = False
End If
End Sub
 
Hi,

you should change this to

Select Case Meeting_Type
Case Is = 1
Controls("Mtg_Subreport").Visible = True
Controls("CC_Subreport").Visible = False
Case Is = 2
Controls("Mtg_Subreport").Visible = False
Controls("CC_Subreport").Visible = True
End Select

Regards,
Alex
 
You're using the wrong event, use the Detail on Format event
 
AVL - Thanks, but I can't seem to get that to work either.

Rich - are you saying that everything except the event procedure is correct? If so, could you help me with the first line?
 
When you need to alter the visibility or other property of a control on a form based on some data value, use the Current event. That event fires every time the record pointer moves. The form's open event is too early since the recordset has not yet been opened when that event runs and the Load event only runs once when the form loads. It doesn't run again if the form is scrolled.

To accomplish the same task in a report, you need to use the Format event of whichever section the control you want to manipulate is located.
 

Users who are viewing this thread

Back
Top Bottom