Results 1 to 5 of 5
  1. #1
    behnam is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    72

    How to create a variable that can be used in all forms.

    Hi all,

    can anyone please tell me how I can create a variable that can be used by all forms.



    Thank you very much!!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    In a module (I use modGLOBAL) , create a GLOBAL variable:

    PUBLIC gsUser as string

  3. #3
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Another option is use of TempVars
    See here for more http://blogs.office.com/2010/09/27/p...2007-and-2010/

  4. #4
    behnam is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    72
    Ranman im not to good at vba so what ur saying is i can create a module and write

    Code:
    PUBLIC gsUser as string
    then i am able to use the variable gsUser in everyform?

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    That is the way. Be careful not to try and use it twice simultaneously.

    Just before using it
    gsUser = ""

    And just after finishing
    gsUser = ""

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

Similar Threads

  1. Replies: 5
    Last Post: 04-04-2014, 03:33 PM
  2. Variable across multiple forms/reports
    By Poyan in forum Access
    Replies: 1
    Last Post: 05-31-2011, 11:03 AM
  3. Pass variable name to another forms
    By Thomman in forum Access
    Replies: 3
    Last Post: 04-07-2011, 10:01 AM
  4. Create a variable from a query created in VBA
    By kaelcarp in forum Programming
    Replies: 4
    Last Post: 06-11-2010, 09:13 PM
  5. using forms control as report variable
    By Seven in forum Reports
    Replies: 3
    Last Post: 12-19-2009, 04:04 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