Results 1 to 8 of 8
  1. #1
    BigPat is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    11

    subform - only select item once

    Hi,



    I've had a browse of the help here but I can't find the answer.

    I have a subform inside an outer form where you're able to select essential skills - the subform takes its data from the 'skills' table, and the outer form feeds into an 'employees' table. The 'skills' table has a list of 20 essential skills, and the person entering the data can type any or all of them. The data from this subform goes into a third table, 'employeeSkills', which is used for matching roles to candidates. The problem is that it's possible for the person inputting the data to choose the same skill more than once. I'm not sure how to set this that you can only select, say, Customer Service once.

    Can someone help please?

    Thanks
    Pat

  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,770
    Your form arrangement doesn't sound right.

    Should be main form bound to Employees and subform bound to EmployeeSkills with a combobox to select skill.

    Preventing duplication of skill for employee can be done several ways.

    1. set the EmployeeID and SkillID fields as compound index in EmployeeSkills table - Access will not allow duplicate pairs - this is the simplest approach

    2. construct combobox RowSource to not include skills in list already assigned to employee - a query that requires joining Skills and EmployeeSkills tables with filter parameter dependent on the EmployeeID of form's current record

    3. VBA code to validate the user input - least desirable approach
    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
    BigPat is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    11
    Thank you. I'll try the compound index idea. I appreciate the help!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Option 2 prevents the event whereas 1 and 3 deal with issue after the fact - annoys users with messages and makes them have to do more work. Downside of option 2 is that dependent comboboxes with alias don't work nice in Continuous or Datasheet view form.

    But if you have the subform set as datasheet, users should be able to see skills already associated with employee and know not to repeat a selection. However, there could be a lot of skills causing a long list to look through - again slowing productivity.

    There is no perfect solution.
    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
    BigPat is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    11
    I think that one's a little out of my league though!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Edited my previous post with more info.

    Dependent combobox not really that complicated. If you want to explore, start with http://datapigtechnologies.com/flash...combobox2.html
    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
    BigPat is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    11
    Yes, I've got some dependent combo boxes in my form actually (location/department). I'm not sure I'd know how to code to eliminate a selection already chosen, though. The rest of my subform is as you say - bound to EmployeeSkills with a Skills combo box.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Require a dataset of all possible employee and skill pairs. This can be generated with a Cartesian query of the Employess and Skills tables. See the nested subquery in example.

    Possible combobox RowSource:

    SELECT EmpSkill.SkillID, EmpSkill.SkillDesc
    FROM (SELECT Employees.EmpID, Skills.SkillID, Skills.SkillDesc FROM Employees, Skills) AS EmpSkill
    LEFT JOIN EmployeeSkills ON (EmpSkill.SkillID = EmployeeSkills.SkillID) AND (EmpSkill.EmpID = EmployeeSkills.EmpID)
    WHERE (((EmployeeSkills.SkillID) Is Null AND EmpSkill.EmpID=Forms!formname!EmpID));
    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: 7
    Last Post: 11-29-2015, 07:24 AM
  2. Replies: 13
    Last Post: 04-15-2015, 08:27 AM
  3. Combo Box Won't Select Last Item in List
    By Autumn227 in forum Forms
    Replies: 9
    Last Post: 12-18-2013, 02:37 PM
  4. Replies: 8
    Last Post: 05-25-2013, 05:24 PM
  5. Can't alays select an item from a list box
    By bomber in forum Access
    Replies: 0
    Last Post: 10-16-2009, 10:01 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