Results 1 to 4 of 4
  1. #1
    f1game is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    2

    Filter records based on another field value

    I have a query (built by another coder) which uses the windows environmental variable to record who is currently logged into the database.



    The query has within the criteria the following statement under EmployeeID field. "DLookUp("ID","tblEmployees","Winlogin = '" & fUsername() & "'")" so is displaying records associated with that employee who match the WinLogin field (who is logged in on windows).

    The tblEmployees also has a "Department" fields which is the department the employee is part of. What I'm trying to achieve is to list all records for the department that the logged in user is part of, not just their records.

    Any assistance would be greatly appreciated.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,566
    So either use another Dlookup for the dept using the ID or username, or bring both back with the one dlookup and split that to get the values.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    f1game is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    2
    Sorry to be so dim, but I'm not sure how to! Help would be gratefully appreciated.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Maybe Department=DLookUp("Department","tblEmployees","[Winlogin] = '" & fUsername() & "'")?
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 5
    Last Post: 02-06-2020, 12:14 PM
  2. Replies: 3
    Last Post: 09-15-2018, 07:41 AM
  3. Replies: 2
    Last Post: 01-20-2017, 10:26 AM
  4. Replies: 19
    Last Post: 04-23-2013, 05:45 PM
  5. Filter records based on multiple checkboxes
    By kbremner in forum Forms
    Replies: 2
    Last Post: 01-18-2011, 10:59 AM

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