Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2016

    Unanswered: linking windows user name to report query

    I have a program that displays reports for many employees. Right now, to get an employee report you enter the name of the employee and a date range and results are displayed for that person. The problem is employees can also see/search for other employees reports. Is there a way to, instead of entering the employee name, that the report automatically fills in the user name from the Windows log in? I know of the =GetUser(), but not sure how to use it here.

  2. #2
    Join Date
    Apr 2014
    Provided Answers: 34
    in a form , put an invisible text box, and at form_load event have it set the username...
    txtUser = Environ("Username")

    then run all queries using the text box as userid
    select * from table where [user]= forms!frmMain!txtUser

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    if its a straightforward situation where ONLY the curent user can view data for that user then getting the userid from environ, or the less compromised network API call works. Although personally I wouldn't bother with hidden controls just add the to the report filter or where clause directly.

    however the problem with that approach is you end up with ONLY being able to see your data. if other people need to see thye same report but with another employee(s) data on you need to rethink the approach. one way round that is to start setting up a user table with a hierarchy in it. eg person A can only see A, person K5 can see A,B,B5.... person Z8 can see K5 (and everyother empoloyee K5 can see and so on.
    I'd rather be riding on the Tiger 800 or the Norton

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