Results 1 to 3 of 3
  1. #1
    GrayB is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Jul 2017
    Location
    Pukekohe, New Zealand
    Posts
    1

    Question Unable to see a Public variable from any Private Subs, Procedures, etc.

    I need to intialise a few variables on startup and made these Public - This is done in the initial switchboard and a MsgBox tells me the value(s) was set. I then need the values to be used as configuration criteria in several subs/procedures, etc. There are no error messages but the Public set value is not accessed (null?). It's got to be something silly?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you place these Public Variables in a Standard Module? That is where they would need to go. Right at the top of the module before any procedures.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Another reason for this might be that the "public" variables have been re-declared in the subs that use them. Declaring them again causes Access to refer to that (local) version - it will not "see" the global one.

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

Similar Threads

  1. Changing private sub dim to public sub dim
    By Stephenson in forum Programming
    Replies: 14
    Last Post: 10-05-2015, 02:59 PM
  2. Replies: 5
    Last Post: 04-27-2015, 02:40 PM
  3. Turning Private Function Into Public
    By g4tv4life in forum Programming
    Replies: 1
    Last Post: 02-04-2014, 05:31 PM
  4. Creating/Using Public Subs
    By sparlaman in forum Programming
    Replies: 3
    Last Post: 05-19-2011, 03:29 PM
  5. Replies: 9
    Last Post: 12-20-2010, 08:05 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