Results 1 to 7 of 7
  1. #1
    Pure Salt is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    60

    Linking a subform to 2 fields

    I am having a mental block.



    I have the following tables - Suppliers, Products, Orders, & Order Transactions.

    I have an order 'main' form which has the order date etc & chosen supplier. My subform links to the main order form by the 'order id', when I click on the combo box for the list of products it shows all products from all suppliers. How can I get it to only show the products for the supplier selected in the main form.

    Probably a simple solution, but I can't think of it!!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    In the query connected to the combo, set the critiera to look at the form.

    where [supplier] = forms!frmMain!txtSupplier

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Will possibly also need code that requeries the combobox when the supplier is selected. Also when navigating records on the main form.

    Try the combobox GotFocus event.

    Me.comboboxname.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.

  4. #4
    Pure Salt is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    60
    Thanks, can't get it to work though.

  5. #5
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    well R256 & J7 advice is the way; so you are having some sort of implementation issue....

    you select the Supplier in a combobox - call it ComboS

    then the selection of a Product is a combobox which has a query record source and when you look at that query it should have the Product field and the Supplier field - even though the supplier field doesn't display in the combobox it must be part of its record source.....so that you can apply the filtering query i.e. Forms!FormName.ComboS

    then as J7 notes - in the AfterUpdate event of ComboS you must tell the Product combobox to requery.....

  6. #6
    Pure Salt is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    60
    Click image for larger version. 

Name:	Untitled.png 
Views:	6 
Size:	18.0 KB 
ID:	18705What am I doing wrong? Tried using combo box name & field name, in various different places & just can't see where I am going wrong. Having a bad day

  7. #7
    Pure Salt is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    60
    Blonde moment over, now working

    Thanks for your help

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

Similar Threads

  1. Subform linking issue
    By buckwheat in forum Access
    Replies: 3
    Last Post: 08-28-2013, 01:53 PM
  2. Replies: 15
    Last Post: 03-05-2013, 11:57 PM
  3. Replies: 0
    Last Post: 03-04-2011, 10:28 AM
  4. Form - subform linking problem
    By Justin in forum Access
    Replies: 1
    Last Post: 11-11-2010, 11:21 AM
  5. Linking form fields
    By rev_ollie in forum Forms
    Replies: 15
    Last Post: 07-09-2010, 06:10 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