Results 1 to 8 of 8
  1. #1
    raghav_pegausis is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    4

    Access 2010 : Current logged in user

    I have a table where i store the records; one of the field is case logged in user and this fields captures data from the environ("username") using VBA. I am writing a query to retrieve the records based on user currently logged to the system and i am unable to do so?



    Can any suggest how to do it in access without using vba? something like

    select * from [table name] where fieldname = currentloggedinuser;

    thanks,

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    When user logs in set a textbox on a form that stays open (a main menu) to the filter criteria (user id). Then refer to this textbox in queries as filter parameter, otherwise call the function that invokes the Environ("USERNAME").
    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
    raghav_pegausis is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    4
    Quote Originally Posted by June7 View Post
    When user logs in set a textbox on a form that stays open (a main menu) to the filter criteria (user id). Then refer to this textbox in queries as filter parameter, otherwise call the function that invokes the Environ("USERNAME").
    Can you give me an example query how to refer to textbox as filter parameter?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    An Access saved query
    SELECT * FROM [table name] WHERE fieldname = Forms!formname!textboxname;
    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.

  5. #5
    raghav_pegausis is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    4
    Quote Originally Posted by June7 View Post
    An Access saved query
    SELECT * FROM [table name] WHERE fieldname = Forms!formname!textboxname;
    I can use this if the form exists in Access; my form exists in excel; can we still use this?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Data is in Access table? You are linking to Access from Excel? You have a form in Excel? Why not all Access?

    I haven't built a form in Excel. I don't know how to get value into textbox on form. Assuming you can accomplish, I guess the query can refer to the textbox. Alternatively, maybe set a cell in worksheet to the criteria and refer to the cell as parameter?

    Please explain full scenario.
    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.

  7. #7
    raghav_pegausis is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    4

    Red face

    Quote Originally Posted by June7 View Post
    Data is in Access table? You are linking to Access from Excel? You have a form in Excel? Why not all Access?

    I haven't built a form in Excel. I don't know how to get value into textbox on form. Assuming you can accomplish, I guess the query can refer to the textbox. Alternatively, maybe set a cell in worksheet to the criteria and refer to the cell as parameter?

    Please explain full scenario.
    I cannot have the form in access due to network drive speed; I have a form in excel which captures data and saves the data in access. while saving the data in access i also pass the current logged in user name to a field in table directly using environ("username") object. This can be accomplished using VBA.

    However when i want to display the statistics of a user i need to retrieve the records based on the current user and this needs based on windows logon. I cannot write a query to do this as access query doesn't take environ("username") as a criteria. this function is not recognized in access.

    Hope i have explained it.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    But because VBA recognizes the Environ function, can have it in a custom public function that can be called by a query or textbox. I have done both.

    I have since been advised to use VBA.Environ("USERNAME")

    Because of network drive speed - too slow? Excel interface is faster?
    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. Replies: 0
    Last Post: 09-27-2011, 12:25 PM
  2. logged user name on main form
    By foxtet in forum Forms
    Replies: 1
    Last Post: 07-30-2011, 03:00 PM
  3. Getusername of currently logged in user
    By nkuebelbeck in forum Access
    Replies: 8
    Last Post: 06-29-2011, 04:06 PM
  4. Replies: 1
    Last Post: 07-14-2010, 01:34 PM
  5. Currently logged in user into text box
    By ne16428 in forum Security
    Replies: 5
    Last Post: 06-10-2009, 11:46 AM

Tags for this Thread

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