Global Variable Declaration

J

John Bigness

I'm inheriting someone else's code who used the Global declaration to declare
variables (see sample code below). Is Global the right thing to use here or
should we be using Public. Any major differences, if any?


Global mydbase As Database
Global rs As Recordset
Global strSQL As String

Option Compare Database
Option Explicit


Public Function CheckSetup()
 
A

Albert D. Kallal

Public and Global are interchangeable .

I not sure which came first...but both remain valid for compatible
reasons....

I have always used public....
 
D

Dirk Goldgar

John Bigness said:
I'm inheriting someone else's code who used the Global declaration to
declare variables (see sample code below). Is Global the right thing
to use here or should we be using Public. Any major differences, if
any?


Global mydbase As Database
Global rs As Recordset
Global strSQL As String

Option Compare Database
Option Explicit


Public Function CheckSetup()

The variable decalaraions really should go *after* the Option
statements, but I guess it doesn't make any difference. The Global
keyword was deprecated when the Public keyword was introduced, but it
works just the same in a standard module..
 

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

Top