Results 1 to 6 of 6

Thread: Global variable

  1. #1
    Join Date
    Mar 2004
    Posts
    128

    Unanswered: Global variable

    Hi,
    I want to know how to define a global variable vb.my targat to check
    if a certain table has been imported to access.the variable will be at first
    0
    my function will be :
    Functrion import()
    if index =0 then
    import table X
    index=1
    end function
    if some one tries to import the same table it will not.

    I defined index but every time I call this function it returned to 0.
    also how I can reset it when I exit access.

    best regards...

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Global variables are declared at the very top of of your module.

    eg:

    Option Compare Database
    Global MyTarget As String

    would declare MyTarget as a globally available string variable.

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    avoid reserved words for your variable names: index has a specific meaning in access: a global variable with the same name as a reserved word could have very confusing repercussions!

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by izyrider
    avoid reserved words for your variable names: index has a specific meaning in access: a global variable with the same name as a reserved word could have very confusing repercussions!

    izy
    I 2nd that motion! DEFINITELY.

    I personally like to use the variable name "Ndx" ...

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    OH, and if you get REALLY bored and jaded, you can start naming your variables after your favorite cartoon characters!!

    Like Taz, Daffy and tweety.

    Fun times!!

  6. #6
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by Teddy
    OH, and if you get REALLY bored and jaded, you can start naming your variables after your favorite cartoon characters!!

    Like Taz, Daffy and tweety.

    Fun times!!
    From my college days ... I liked doing this: create a variable (loop control) called HungAtHighNoon ... Then:

    Do While True
    ...

    Until HungAtHighNoon

    Aren't I sick????

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •