Results 1 to 5 of 5
  1. #1
    futurezach is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2013
    Posts
    2

    Global Variables?

    Hi all,

    I am creating a report that is basically a set of different queries displayed on one page. Most of these queries require a start date and end date to be entered before it spits out the statistics. The only problem is that because I have 8-10 queries, I have it asking for a start date and end date 8-10 times. Is there a way to create a kind of "global variable" that all I need to do is enter it once and this copies the value over to all queries? Apologies if this is a dumb question but I am relatively new to access (i'm using 2003), and all the books make no mention of this functionality.



    Thanks!

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    You can declare say StartDate and EndDate as global variables. In the queries, use these variables as criteria. Always remember to assign them values before these queries are called.Other option is use a form which is always open or a hidden form and populate two text boxes on this form with the date ranges you need.

  3. #3
    futurezach is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2013
    Posts
    2
    Okay, but how do I declare global variables?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you *always* running these reports from a form? If so then the queries can reference controls on that form rather than using Global Variables.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    FYI: Global Variables are simply Public variables declared in a Standard Module rather than in a code module for a form.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-29-2013, 12:40 PM
  2. Global Property Changes
    By ajetrumpet in forum Code Repository
    Replies: 2
    Last Post: 08-07-2012, 10:31 PM
  3. Replies: 2
    Last Post: 12-23-2011, 08:22 AM
  4. Global variable
    By ramdandi in forum Queries
    Replies: 3
    Last Post: 12-18-2011, 01:01 AM
  5. Setting global variables
    By Remster in forum Programming
    Replies: 1
    Last Post: 08-24-2011, 08:47 AM

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