Results 1 to 4 of 4
  1. #1
    AccessDenial is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Aug 2018
    Posts
    8

    Displaying combo box or combo box options depending on foreign key

    Hi all! Hope to seek your advice on the following situation.



    I am creating a table and (more importantly a) form for a mini stall which sells sweets and toys for the purpose of tracking a few common variables such as the date the items were bought. However, there are:
    a: some items with common variables but options specific to item type such as Sweets with only Sweet Suppliers.
    b. some items with specific variables such as sweets which have sweetness level and toys which doesn't.

    Item Type Bought Date Supplier Sweetness
    Sweet A 10 May 2018 SweetSupplier 1 50%
    Sweet B 15 May 2018 SweetSupplier 2 90%
    Toy 1 2 June 2017 ToySupplier 1
    Toy 2 2 June 2017 ToySupplier 2



    Question 1: I plan on creating a form so my staff can easily scroll through each item. Is it recommended I place all of them in the same database to begin with?

    Question 2: In my form there will be a combobox for my staff to easily select the supplier for the item type. Is there a way to only show Sweet Suppliers and not a whole list of suppliers when the Item Type is a Sweet?

    Question 3: How do I display the Sweetness field in my form only when the Item Type is a Sweet?

    Thank you.

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    In answer to your questions
    1. Yes. Same database. Same table. Suitable fields to distinguish them.
    Suggest field ItemName e.g. Sweet A as well as ItemType e.g. Sweet, toy etc
    2. Filter your suppliers combo box by the item type e.g sweet
    3. Make the Sweetness control hidden by default.
    If a sweet is selected using the combo, add code to the combo after update event to make the control visible.
    Ask if you need help with code for this.
    Note that this will only work if you have a single form
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    This is known as cascading or dependent comboboxes/listboxes. Very common topic. However, as Colin notes, does not work nice in continuous or datasheet form when lookups have alias values.
    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.

  4. #4
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    To expand on June's answer, one combo to select the supplier and another to then select a specific item available from that supplier
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

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

Similar Threads

  1. Replies: 39
    Last Post: 03-15-2017, 07:34 PM
  2. Subform depending on a combo box selection but...
    By stephanie77 in forum Access
    Replies: 12
    Last Post: 01-22-2017, 01:06 PM
  3. Replies: 1
    Last Post: 02-06-2016, 05:33 AM
  4. Replies: 7
    Last Post: 03-30-2015, 10:04 AM
  5. Replies: 2
    Last Post: 03-04-2011, 10:12 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