Setting Visible based on Report value

  • Thread starter Thread starter Cameo
  • Start date Start date
C

Cameo

I'm trying to set some headers and footers of a report to visible or
invisible depending on a value of a control in the report.

I think I have a syntax error, but I don't know what it is...

The code I have is:

Private Sub Report_Open (Cancel as Integer)
If Me.NotesTypeID = 33 then Me!SponsorEventHeader.Visible = False
End Sub

The above returns an error. I've tried adding parens (Me.NotesTypeID = 33)
but that doesn't seem to work?

Can someone tell me what I'm doing wrong?

Thank you!

Cameo
 
Hi Ken,

I have the report grouped with various headers and footers, not just the
Report Header. I named the specific one I wanted to set visible/not visible
as "SponsorEventHeader" (was originally GroupHeader0)

I removed the exclamation point and thus changed my code to
If Me.NotesTypeID = 33 then Me.SponsorEventHeader.Visible = False

and it returned the following error:
Run-time error '2427':
You entered an expression that has no value.

What else can I try?

Thank you so much for helping!

Cameo
 
Cameo said:
I'm trying to set some headers and footers of a report to visible or
invisible depending on a value of a control in the report.

I think I have a syntax error, but I don't know what it is...

The code I have is:

Private Sub Report_Open (Cancel as Integer)
If Me.NotesTypeID = 33 then Me!SponsorEventHeader.Visible = False
End Sub

The above returns an error. I've tried adding parens (Me.NotesTypeID
= 33) but that doesn't seem to work?

Can someone tell me what I'm doing wrong?

I don't think bound report controls have a value yet in the report's
open event. Try moving your code to the Format event of a report
section; maybe the Report Header section.
 
That did the trick! Thank you!!!

Cameo

Dirk Goldgar said:
I don't think bound report controls have a value yet in the report's
open event. Try moving your code to the Format event of a report
section; maybe the Report Header section.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top