Results 1 to 12 of 12
  1. #1
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49

    Limit choices in a combobox based on the value in another combobox

    I'm using Access 2010. I've created a form called Enter_Clients with a subform called Enter_Sales_Subform. In the subform, I have 2 comboboxes, CompanyID and ProductID. After entering a value in CompanyID, I'd like to limit the values that show up in the ProductID combobox based on the values in tbl_Companies_Products (including the Active value being "1" or "True").

    Anybody know how to do that?

    Thanks in advance!


    Doug
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Called cascading or dependent comboboxes. Review: http://www.datapigtechnologies.com/f...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.

  3. #3
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49
    June7, you are a wealth of knowledge. I am truly amazed!

    It seems like I'm almost there. Now, Access is popping up an "Enter Parameter Value" dialogue box. It says "Forms!Enter_Sales_Subform.cmbCompanyID" under the heading.

    I've double and triple checked each setting and don't see anything that jumps out at me. Any ideas?!?

  4. #4
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49
    Here is an updated version of the database. If anyone else has any ideas, please feel free to share your thoughts!

    Thanks!
    Doug
    Attached Files Attached Files

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    There is no reason to include tbl_Sales in the RecordSource for Enter_Clients.

    Don't include form reference prefix in RowSource for Product combobox:

    SELECT tbl_Products.ProductName FROM tbl_Products INNER JOIN (tbl_Companies INNER JOIN tbl_Companies_Products ON tbl_Companies.CompanyID = tbl_Companies_Products.CompanyID) ON tbl_Products.ProductID = tbl_Companies_Products.ProductID WHERE (((tbl_Companies.CompanyID)=[cmbCompanyID])) GROUP BY tbl_Products.ProductName, tbl_Companies_Products.ProductID;

    Understand that cascading comboboxes with alias don't work nice in Continuous or Datasheet view form.
    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
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49
    June7, that worked perfectly. I am so very thankful for your help!!

    AWESOME!!!!!

  7. #7
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49
    Okay, so there is apparently still one small bug. I was testing the database before launching it and discovered an issue.

    When entering a new customer with the sales information on the before mentioned form/subform, Access gave an error message saying "The Microsoft Access database engine cannot find a record in the table 'tbl_Products' with key matching field(s) 'CompanyProductID'."

    Anyone have any ideas what may be causing the error message?

    Click image for larger version. 

Name:	ClientSale.JPG 
Views:	17 
Size:	34.9 KB 
ID:	18805

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Would have to review the data structure and form and control properties. If you want to provide db, follow instructions at bottom of my post.
    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.

  9. #9
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49
    Here is the zipped file.

    Thanks again!
    Attached Files Attached Files

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    To repeat my earlier comment: There is no reason to include tbl_Sales in the RecordSource for Enter_Clients.
    Including tblSales with an INNER JOIN actually can cause issue - INNER JOIN requires related records in both tables to already exist.

    Similarly, there is no reason to include tbl_Companies and tbl_Products in the RecordSource for the subform. However, if you do include them, cannot be an INNER JOIN (see note above). Change to RIGHT JOIN. If you bind any textboxes to the fields of those two tables, set them Locked Yes and TabStop No to prevent editing, only for display. And since you did not bind any textboxes to those fields, including those tables is totally unnecessary.

    Could just reference the tables in the RecordSource, a query is not required.
    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.

  11. #11
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49
    What do you think would be the best way for a user to log clients and sales together in one screen? Or should that be two different forms?

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    The form/subform arrangement is appropriate, just fix each RecordSource.
    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: 1
    Last Post: 05-24-2014, 09:08 AM
  2. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  3. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 PM

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