Results 1 to 7 of 7
  1. #1
    kevinoc is offline Novice
    Windows Vista Access 2013
    Join Date
    Oct 2015
    Posts
    3

    Login Temp_Variable to populate in tables

    Hi,

    I have set up a login form to assign a temporary variable to the current session, which will be the username. I am now having difficulty getting this value to propagate elsewhere. I need this value to go to the various forms elsewhere.

    For context, main login form sets the temporary variable, TempVars!TempLoginID; I want this TempVars!TempLoginID to go to other tables and forms for that session, so to allow tracking of what user entered what.

    Please advise as a matter of urgency.

    Thank you and appreciated

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    I've never used TempVars. I set value of a textbox on form that never closes (Main Menu). Then that textbox is always available for reference.

    Another option is a VBA global variable declared in a general module. However, be aware that if code execution is interrupted the variable will lose value.
    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.

  3. #3
    kevinoc is offline Novice
    Windows Vista Access 2013
    Join Date
    Oct 2015
    Posts
    3
    Quote Originally Posted by June7 View Post
    I've never used TempVars. I set value of a textbox on form that never closes (Main Menu). Then that textbox is always available for reference.

    Another option is a VBA global variable declared in a general module. However, be aware that if code execution is interrupted the variable will lose value.
    Hi,

    The reason I am using tempvars is that we will have different users - a set user would not serve our purposes. I will look into the global variable, but I think there may be something to simply getting a form/table to read the variable entered by the user initially.

    Thanks

  4. #4
    jtgarrison is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2013
    Posts
    2
    Something I started using a few years ago was a "database variables" table, where I store pertinent information for a user's session. It's stored on the front end client. I store things like User Name, Report Start Date, Report End Date, and any other temporary items you would need. You would need to initially add one record so that you can update for that record. Once the record has been updated, you can easily do a dlookup of that field in the database variables table.

    Hope this helps. It has saved me alot of aggravation over the years.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    I don't have a 'set' user. The textbox is dynamically populated with user's info when they open the db. I have a table of users with their network username and initials. I pull username with Environ("USERNAME") and do a lookup on table for initials. Initials go in the textbox.
    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.

  6. #6
    kevinoc is offline Novice
    Windows Vista Access 2013
    Join Date
    Oct 2015
    Posts
    3
    Quote Originally Posted by June7 View Post
    I don't have a 'set' user. The textbox is dynamically populated with user's info when they open the db. I have a table of users with their network username and initials. I pull username with Environ("USERNAME") and do a lookup on table for initials. Initials go in the textbox.
    Thank you, folks.

    On the above, would the likes of the following link be the best article to use?

    http://access.mvps.org/access/api/api0008.htm

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Could - but I don't use API function to get user's network ID. I use VBA function: Environ("USERNAME").

    API functions can cause issues when db run on different computers. On my Windows 7 64-bit machine, I have to use PtrSafe in API function call or I get compile error.
    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.

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

Similar Threads

  1. Login to linked tables at beginning of code
    By nigelbloomy in forum Programming
    Replies: 3
    Last Post: 09-23-2015, 09:20 AM
  2. Replies: 2
    Last Post: 04-17-2015, 10:59 AM
  3. Replies: 0
    Last Post: 03-09-2015, 06:16 PM
  4. Access 2010 login to connect to linked tables
    By Back2Access in forum Security
    Replies: 3
    Last Post: 02-13-2015, 10:45 AM
  5. Linked tables SQL Server login popup
    By geremore in forum Programming
    Replies: 3
    Last Post: 08-16-2011, 12:47 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