SSRS 2008 Report Code Not Working

Below Report code not working. Found it on the internet.
I am trying to find if my report is on page 1 or not so I can control the printing of a line thru-out report.

Public Shared Function PageOn (ByVal PageNumber() as string) as string
Dim str as string
If Globals!PageNumber = 1 then str = "False"
Else str = "True"
End If
Return str
End Function

In report and  using for line visibility:
=iif(code.PageOn = False,False,True)

Error:
Reference to a non-shared member requires an object reference.

If there is a better way to write this code and it works, I'm in...
thayduckProgrammer AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vikas GargAssociate Principal EngineerCommented:
Hi,

Try this

Function PageOn (ByVal PageNumber() as string) as string
Dim str as string
IF Me.Report.Globals!PageNumber = 1 Then 
str = "False"
Else 
str = "True"
End If
Return str
End Function 

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thayduckProgrammer AnalystAuthor Commented:
Getting attached error when executing report.

Visibilty Line code I am using this Report Custom Code on:

=IIF(code.PageOn = "False", False,True)
PageOnError.PNG
thayduckProgrammer AnalystAuthor Commented:
Below Custom Code works, but , =IIF(code.PageNumber() = 1, False,True)  always shows False no matter what page report is on.  code.PageNumber() is always 1.

Public Function PageNumber() as string
Dim str as String
str = me.Report.Globals!PageNumber.ToString()
Return str
End Function
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSRS

From novice to tech pro — start learning today.