Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2002
    Posts
    121

    Red face Unanswered: global Variables

    Hello,
    I'm trying to user a global variable such that when a button is pressed on Form "A", form "A's" name is stored in that global variable, g_source, for another form, Form "B" to accesss. However, when I click a button on Form "B" that uses g_source an error is thrown saying that the method requires a form name argument (this would be g_source). It seems to me that my g_source is out of scope but I don't understand why? I declared it the General Declarations section of Form "A." Was this the proper place to delare it? See below.....

    Option Compare Database
    Option Explicit
    Public gSourceForm As String
    Public strChart As String

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    How are you calling the form?

    I this context, forms(gSourceForm) should work...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Aug 2002
    Posts
    121
    Ted,
    I am calling the form from the "click event" of a button on Form "B"...

    DoCmd.OpenForm g_SourceForm, , , "username = currentuser() "

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    g_SourceForm or gSourceForm?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Aug 2002
    Posts
    121
    Actually, gSourceForm is the name of the variable in both the General Declaration and the "click event." In my original post, I called it g_source for brevity purposes.


  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Alright, try moving your declaration into a module and declaring it as:

    Global gSourceForm As String
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Aug 2002
    Posts
    121

    Talking

    Yes, that worked!! Thanks Ted



Posting Permissions

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