Global Data?

  • Thread starter Thread starter nathan sanders
  • Start date Start date
N

nathan sanders

Hi,

Is there a way of storing a global variable, suach as a month/year so that i
can use that in reports and queries without having to declare/change it in
every instance

Cheers

Nathan
 
Nathan,

You can declare a public variable (or variables) in a standard module:
Public g_iMonth As Integer
Public g_iYear As Integer

Then put a value into it from anywhere (except queries)
g_iMonth = intMyMonth
g_iYear = intMyYear

Or you can put it all in the one variable:
Public g_sMonthYear As String

....and refer to it like so:
g_sMonthYear = Format(intMyMonth, "00") & Format(intMyYear, "2000")

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Hi,

Is there a way of storing a global variable, suach as a month/year so that i
can use that in reports and queries without having to declare/change it in
every instance

In addition to the global variable approach Graham suggests, one idea
is to have an always-open Form (such as a switchboard) with textboxes
for such generally used information. You can then refer to

=[Forms]![frmSwitchboard]![txtYear]

in your queries.

John W. Vinson[MVP]
 
Thank you Graham.



Graham R Seach said:
Nathan,

You can declare a public variable (or variables) in a standard module:
Public g_iMonth As Integer
Public g_iYear As Integer

Then put a value into it from anywhere (except queries)
g_iMonth = intMyMonth
g_iYear = intMyYear

Or you can put it all in the one variable:
Public g_sMonthYear As String

...and refer to it like so:
g_sMonthYear = Format(intMyMonth, "00") & Format(intMyYear, "2000")

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Thanks John.



John Vinson said:
Hi,

Is there a way of storing a global variable, suach as a month/year so that
i
can use that in reports and queries without having to declare/change it in
every instance

In addition to the global variable approach Graham suggests, one idea
is to have an always-open Form (such as a switchboard) with textboxes
for such generally used information. You can then refer to

=[Forms]![frmSwitchboard]![txtYear]

in your queries.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top