Results 1 to 5 of 5
  1. #1
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228

    Global Array


    I am looking at making somewhat of a "global array", if you would. To compare what I am trying to do to something in much simpler terms... consider shuffling a deck of cards. You shuffle it once, and come back to it multiple times. I can randomize the array to a final output, but how do I make it global, so it doesn't disappear after the code is complete and I can retrieve the randomized array at later times. I also am not looking to write it to a table or something of that sort.

  2. #2
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Dismiss this, the very next idea I tried ended up working.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Declare the array in a general module. Then any procedure can reference it. Be aware that global variables lose their value if code execution is interrupted by error and then terminated.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I would suggest saving that array as a table of values. That is how you preserve the data from one access session to another. What is your rationale for not using a table? Then again, you can always create a randomized array-why would you need to keep it from session to session?

  5. #5
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    The mistake I was making was declaring a global array with a defined number of elements, and then defining those elements as a constant, before rearranging them.

    I.E.

    Code:
    Global array1(5) As Variant, array2(5) As Variant
    
    Function test()
    array1()  = Array("1", "2", "3", "4", "5", "6")
    
    'Code to randomize and place into array2
    
    End Function
    That was my mistake. I have my desired results, no need to look further into this.

    Thanks though guys.

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

Similar Threads

  1. Global Error
    By Thompyt in forum Programming
    Replies: 4
    Last Post: 01-10-2015, 01:28 PM
  2. Global Variable
    By gtg430i in forum Programming
    Replies: 11
    Last Post: 03-10-2014, 05:00 PM
  3. Can't See Global Variable
    By CementCarver in forum Programming
    Replies: 12
    Last Post: 09-19-2013, 12:28 PM
  4. Global Variables?
    By futurezach in forum Reports
    Replies: 4
    Last Post: 06-20-2013, 03:45 PM
  5. Global Property Changes
    By ajetrumpet in forum Code Repository
    Replies: 2
    Last Post: 08-07-2012, 10:31 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