Results 1 to 2 of 2
  1. #1
    SteveApa is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    84

    Global Public Array

    Hi.

    I am trying to create a global public array. I created a module called "GlobalVariables". In that Module I have this code..
    Code:
    Option Explicit
    
    
    Public ELEMENTS_QUERIES As string
    ELEMENTS_QUERIES = Array("2d1) Gate to Business Element", "2d2) Gate to Core Element", "2d3c) Gate to Cost Element", "2d4) Gate to Feature Element", _
                            "2d5) Gate to Perf Element", "2d6) Gate to Budget Element", "2d7) Gate to Sched Element")
    On compile, I get error "Compiler Error: Invalid outside procedure" - it highlights the first string in the array - "2d1) Gate to Business Element"

    I tried this also..
    Code:
    Option Explicit
    
    
    Public ELEMENTS_QUERIES(1 To 7) As String
                            
    ELEMENTS_QUERIES(1) = "2d1) Gate to Business Element - Qry"
    ELEMENTS_QUERIES(2) = "2d2) Gate to Core Element - Qry"
    ELEMENTS_QUERIES(3) = "2d3) Gate to Cost Element - Qry"
    ELEMENTS_QUERIES(4) = "2d4) Gate to Feature Element - Qry"
    ELEMENTS_QUERIES(5) = "2d5) Gate to Perf Element - Qry"
    ELEMENTS_QUERIES(6) = "2d6) Gate to Budget Element - Qry"
    ELEMENTS_QUERIES(7) = "2d7) Gate to Sched Element - Qry"
    I also tried this...
    Code:
    Option Explicit
    
    
    Public ELEMENTS_QUERIES As String
     
    Public Function Set_Global_Variables()
        
        ELEMENTS_QUERIES = Array("2d1) Gate to Business Element", "2d2) Gate to Core Element", "2d3c) Gate to Cost Element", "2d4) Gate to Feature Element", _
                            "2d5) Gate to Perf Element", "2d6) Gate to Budget Element", "2d7) Gate to Sched Element")
    End Function
    I get the same error.

    How can I create an populate a global array???

    Thanks.
    Steve
    Harrisburg, PA USA

  2. #2
    SteveApa is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    84
    Got.. This works.
    Option Explicit

    Code:
    Public ELEMENTS_QUERIES() As Variant
     
    Public Function Set_Global_Variables()
        
        ELEMENTS_QUERIES = Array("2d1) Gate to Business Element", "2d2) Gate to Core Element", "2d3c) Gate to Cost Element", "2d4) Gate to Feature Element", _
                            "2d5) Gate to Perf Element", "2d6) Gate to Budget Element", "2d7) Gate to Sched Element")
    End Function

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

Similar Threads

  1. Global Array
    By kdbailey in forum Access
    Replies: 4
    Last Post: 05-19-2015, 03:04 PM
  2. Can't See Global Variable
    By CementCarver in forum Programming
    Replies: 12
    Last Post: 09-19-2013, 12:28 PM
  3. How to use global/public variable
    By mrbabji in forum Programming
    Replies: 7
    Last Post: 05-18-2013, 10:08 PM
  4. Global Property Changes
    By ajetrumpet in forum Code Repository
    Replies: 2
    Last Post: 08-07-2012, 10:31 PM
  5. Global variable
    By ramdandi in forum Queries
    Replies: 3
    Last Post: 12-18-2011, 01:01 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