make subreport2 visible based on condition

Help, I am running Access 2003 and have
trouble getting this work right.

I have an unbound subreport that contains 3
additional subreports.  I want only one of the 3
to be visible based on the value in a combo
box on a selection form.  I can't seem to get
the reference right and have tried several
variations.

    If Forms!frmWeeklyGLrpt!cboCC = 1 Then
   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDA.Visible = True
   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDB.Visible = False
   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDC.Visible = False
   End If
    If Forms!frmWeeklyGLrpt!cboCC = 2 Then
   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDA.Visible = False
   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDB.Visible = True
   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDC.Visible = False
   End If
    If Forms!frmWeeklyGLrpt!cboCC = 3 Then
   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDA.Visible = False
   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDB.Visible = False
   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDC.Visible = True
   End If

I keep getting Runtime error 2455
"You entered an expression that has an invalid reference to the
property
Form/Report."

Can anyone help me out?
0
Opal
12/14/2009 6:44:10 PM
access.reports 4434 articles. 0 followers. Follow

1 Replies
1116 Views

Similar Articles

[PageSpeed] 45

Opal wrote:

>Help, I am running Access 2003 and have
>trouble getting this work right.
>
>I have an unbound subreport that contains 3
>additional subreports.  I want only one of the 3
>to be visible based on the value in a combo
>box on a selection form.  I can't seem to get
>the reference right and have tried several
>variations.
>
>    If Forms!frmWeeklyGLrpt!cboCC = 1 Then
>   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDA.Visible = True
>   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDB.Visible = False
>   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDC.Visible = False
>   End If
>    If Forms!frmWeeklyGLrpt!cboCC = 2 Then
>   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDA.Visible = False
>   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDB.Visible = True
>   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDC.Visible = False
>   End If
>    If Forms!frmWeeklyGLrpt!cboCC = 3 Then
>   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDA.Visible = False
>   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDB.Visible = False
>   Me!subrptGLWeekly.Report!subrptGLWeeklyCMRDC.Visible = True
>   End If
>
>I keep getting Runtime error 2455
>"You entered an expression that has an invalid reference to the
>property Form/Report."
>

I think that happens if your code is in the main report's
Open event.  Try moving it to the report header's Print
event or maybe you need it in the main report section that
contains the subrptGLWeekly subreport.

-- 
Marsh
MVP [MS Access]
0
Marshall
12/14/2009 9:05:07 PM
Reply:

Similar Artilces: