Global Variable Declaration

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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()
 
Public and Global are interchangeable .

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

I have always used public....
 
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..
 
Back
Top