Results 1 to 5 of 5
  1. #1
    vicrauch is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Sacramento
    Posts
    27

    Is there any way to use a global variable in a query?

    I'm looking for a way to use a global variable in a query. What I have done in the past is used a hidden form to store global variables, then reference the form within the query. But I was hoping that there is a way to use a class variable or a class property in a query.


    Any ideas?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I don't believe there's any way to use it directly. The usual solution is to create a public function that returns the value of the variable, and call the function from the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    vicrauch is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Sacramento
    Posts
    27
    Thanks Paul. Coming from you settles it for me, "Can't be done." I will stick to my hidden form idea that I have used successfully for over 15 years. I've just been away for Access for about 4 years now, so just trying to catch up again. Nice part is, it's coming back quite well.
    Vic

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help Vic, though your confidence is misplaced. The fact that I don't know how to do something doesn't mean it can't be done.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    vicrauch is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Sacramento
    Posts
    27
    "The fact that I don't know how to do something doesn't mean it can't be done."
    But, the fact that nothing pops into your mind, is enough that it more than likely can't be done. At least, is not worthy to be pursued. Plus the fact that I did not think it could be done in the first place, and with you "agreeing," then I'm done looking.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Global Property Changes
    By ajetrumpet in forum Code Repository
    Replies: 2
    Last Post: 08-07-2012, 10:31 PM
  2. How to declare Global Variable
    By ganeshvenkatram in forum Access
    Replies: 1
    Last Post: 06-16-2011, 05:18 AM
  3. Dlookup in query using Global variable
    By newwales in forum Access
    Replies: 1
    Last Post: 06-03-2011, 03:47 PM
  4. Declare a Global Variable and Use it on Forms
    By jackkent in forum Access
    Replies: 9
    Last Post: 10-07-2010, 10:19 AM
  5. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums