Results 1 to 2 of 2
  1. #1
    lvivianl is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    1

    How to hide records in mainform when subform is empty?


    I have two tables - one for Customer with a unique customer_ID as the primary key, and another one for Order. Regret to say many of the customers in my contact list haven't yet made any orders. When I create a form having Customer in the main form and Order in the subform, it always include all the records from the Customer table. Is it possible to create a Form with sub-form only showing records when subform is not blank? Please note I have already set the "Join Type" in relationship to Option 3, i.e. include all records from Orders and only records from Customers when the joined fields are equal, and I can also see the "right outer join arrow" in the relationship diagram. Whatelse have I missed

  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,628
    Setting relationships does not dictate records retrieved by forms. Need to apply a filter to the main form that excludes customers without orders. This will be tricky because customarily child does not control parent. Do you want the main form record to still be editable?

    Have to query the Order table to determine if records for customer exist. Options are a nested subquery or DLookup (or DCount) in the form RecordSource. Like:

    SELECT * FROM Customer WHERE Not DLookup("CustomerID","Order","CustomerID=" & [CustomerID]) Is Null);
    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. if report qty is empty hide all details
    By mathanraj76 in forum Reports
    Replies: 4
    Last Post: 06-11-2013, 12:07 AM
  2. Replies: 1
    Last Post: 11-07-2012, 05:31 PM
  3. Hide Empty SubReport
    By mystifier in forum Reports
    Replies: 0
    Last Post: 06-08-2012, 01:10 AM
  4. Replies: 4
    Last Post: 03-30-2012, 01:47 AM
  5. Replies: 1
    Last Post: 11-29-2011, 01:37 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