[AccessD] Public Variables - Scope and Lifetime

Robert Gracie robert at servicexp.com
Fri Nov 25 12:29:37 CST 2005


This is how I do it on forms....  create Properties

Main form
Module Level Variable (Top of form)

Private m_bPrintPageHeader         As Boolean


Create Properties

Public Property Get PrintPageHeader() As Boolean
    PrintPageHeader= m_bPrintPageHeader
End Property
Public Property Let LinkType(ByVal sPrintPageHeader As Boolean)
    m_bPrintPageHeader = sPrintPageHeader
End Property 


You can then access this information from the subform as such

With Me.Parent
If .PrintPageHeader = true then
 'Do something
End If

Keep in mind the order in which the forms load...

Robert Gracie
www.gbsysnow.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Borge Hansen
Sent: Thursday, November 24, 2005 11:30 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Public Variables - Scope and Lifetime

I first tried to use an unbound textcontrol  on the main report, setting
the value along the way, referencing the control me.txtControl or
me.parent.txtcontrol However, didn't work......

So I thought: use a public variable.
But how to prevent it going out of scope?

If - as you say - I only have to declare a public variable once, like in
the main report class module, how do I reference and set the value of
the variable within the subreport class module?

This is fundamental stuff, but I never got it (sigh!)

in small font:
/borge
;)

SNIP



More information about the AccessD mailing list