Results 1 to 6 of 6
  1. #1
    Jenepher White is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    1

    Question Dropdown list to allow distinct values

    I am creating a form with a dropdown list. I want it to remove a value from the dropdown once it's been selected in the form. To ensure no duplicates.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Unclear. But if in a continuous form of records... If row 1, user picks A, then row 2, A can no longer be a picked.

    IF so, you need a query with an IN clause . If tEntry.field with any rows , and tChoices.field NOT in tEntry.field

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If you are talking about a Combobox, use WHERE criteria in the Combobox's RowSource that considers the User's input. Then, requery your combo to reflect changes made via the User's input. Me.ComboName.Requery

  4. #4
    richardm55 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Location
    Birmingham, UK
    Posts
    20
    Quote Originally Posted by ItsMe View Post
    If you are talking about a Combobox, use WHERE criteria in the Combobox's RowSource that considers the User's input. Then, requery your combo to reflect changes made via the User's input. Me.ComboName.Requery
    Could you explain exactly how to do it? Could you write example syntax for WHERE criteria in Combobox's RowSource?

  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,772
    Maybe this will work:

    As example, say combobox lists employees and is to select an employee for a task. There is a table of Employees and a table of Tasks and a junction table EmployeeTasks that associates employees with tasks and the combobox is on a subform bound to EmployeeTasks and main form is bound to Tasks. Combobox RowSource:

    SELECT EmpID FROM Employees WHERE NOT EmpID IN (SELECT EmpID FROM EmployeeTasks WHERE TaskID = [TaskID]);

    Code in combobox GotFocus event:

    Me.cboEmployee.Requery
    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
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    SELECT EmpID FROM Employees WHERE NOT EmpID IN (SELECT EmpID FROM EmployeeTasks WHERE TaskID = [TaskID]);
    That's pretty slick. This way you do not have to build a WHERE clause. Your subform is the WHERE clause.

    @ richardm55
    What is the process that the user goes through? Understanding the Business Logic/Rules might help us.

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

Similar Threads

  1. Add to the dropdown list
    By tanyalee123 in forum Forms
    Replies: 1
    Last Post: 11-13-2013, 01:18 PM
  2. Dropdown list
    By imintrouble in forum Access
    Replies: 2
    Last Post: 01-20-2012, 08:09 AM
  3. Dropdown list
    By stratack in forum Access
    Replies: 1
    Last Post: 07-25-2011, 06:58 AM
  4. Set up a dropdown List
    By asherbear in forum Access
    Replies: 2
    Last Post: 06-24-2010, 06:45 AM
  5. Distinct Values
    By Acramer8 in forum Reports
    Replies: 1
    Last Post: 06-15-2009, 08:37 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