Results 1 to 15 of 15
  1. #1
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66

    Main, Junction Query (I have been trying for two days)

    My main table is tblMainFile
    I have junctions (listed) which leads to (listed)

    1. tblJncFileDelivery ---> tblDatDelivery (6 rows of choices - Can have multiple choices as a file can be delivered different ways)
    2. tblJncFileAudience--->tblDatAudience (10 rows of choices - Can have multiple choices as a file can be delivered to different audiences)
    3. tblJncFileTopic------>tblDatTopic (30 rows of choices - Can have multiple choices as a file can have multiple topics)

    The tblMainFile is tied to the various junctions with a PK.

    I am trying to create a query which will allow the user to Select (from a combobox) data from tblDatDelivery (and/or) data from tblDatAudience (and/or) data from tblDatTopic

    The challenge is, when I create the query, I am getting duplicate records unless I fill in all three of the comboboxes!

    The reason is, the item from tblMainFile can have ONE link to tblDatDelivery but MULTIPLE links to tblDatAudience and tblDatTopic (and vice versa)

    I'm thinking I have to do three queries (one for each pull down box) and then somehow pull the data together when I click a button, but I can't figure out how to make this happen!



    Any help would be GREATLY APPRECIATED!

    Joe

  2. #2
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    Is there more information that I can provide which would help answering my question?

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I don't know if I can help you, but.....

    It would help to see:
    what your table structures are; what fields are in which tables.
    example data from each table...


    I'm thinking I have to do three queries (one for each pull down box) and then somehow pull the data together when I click a button, but I can't figure out how to make this happen!
    From your description, I would have 3 sub forms (maybe on tabs). There could be a combo box on the subform to make the selections.

    Maybe post your dB? (delete/change any sensitive data)

  4. #4
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    Click image for larger version. 

Name:	Document2.jpg 
Views:	36 
Size:	84.9 KB 
ID:	13911
    Here is the current structure.
    Let me know if you need anything else.

  5. #5
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    Is there anything else I can offer so someone can help me?
    I'm about to give up but I know this is possible.

  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
    Bizarre data structure. Don't understand it at all and I have tried to in your other threads.
    Maybe this is relevant: http://www.codeproject.com/Articles/...atabase-Design
    Last edited by June7; 10-01-2013 at 11:25 AM.
    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
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I am trying to create a query which will allow the user to Select (from a combobox) data from tblDatDelivery (and/or) data from tblDatAudience (and/or) data from tblDatTopic
    I am not sure what you are trying to do with the "query".

    I have to agree with June7..... this is a very strange structure.

    But... is the attached mdb close to what you are trying to do?
    There are two different "Main" forms: "MainJunction" that has a tab control with subforms and "MainJunction2" that has subforms in the footer.

  8. #8
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    After some considerations, I made changes to the database.
    I think this makes more sense but my original question still holds true on what I am trying to accomplish.
    Here is the new structure and the new database.
    teamtoolbox1.zipClick image for larger version. 

Name:	Doc1.jpg 
Views:	26 
Size:	75.2 KB 
ID:	13970

    When you open this up... you can see that I have a few forms for inputting information.
    frmInputCourse
    frmInputFiles

    What I am looking for are two forms which allows the user to do the following:

    Form 1 (Course Search) - Using three combo boxes, (Audience / Delivery / Topic) Allow the user to find the course(s) associated with any, or all of the three combo box choices.
    Form 2 (File Search) - Using three combo boxes, (Audience / Delivery / Topic) Allow the user to find the file(s) associated with any, or all of the three combo box choices.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Each MainCourse can have multiple Delivery, multiple Email, multiple Topic, multiple Audience?

    Each Delivery, Email, Topic, Audience can associate with more than one MainCourse?
    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.

  10. #10
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    To answer your main question, don't put the query together into a single query. When a person fills in one or more dropdownboxes, have the results displayed in three different listboxes - one for available delivery methods, one for available audiences, one for included topics.

    They will all be based upon a single query that includes all the selected limitations, but each listbox will only display the single characteristic for that list box, based on a GROUP BY on that characteristic.

    Code:
    Query1:
    SELECT Course, Delivery, Audience, Subject
    FROM Whatever
    WHERE Whatever;
    
    QueryA:
    SELECT Audience
    FROM Query1
    GROUP BY Audience;
    
    QueryD:
    SELECT Delivery
    FROM Query1
    GROUP BY Delivery;
    
    QueryS:
    SELECT Subject
    FROM Query1
    GROUP BY Subject;

  11. #11
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    Quote Originally Posted by June7 View Post
    Each MainCourse can have multiple Delivery, multiple Email, multiple Topic, multiple Audience?

    Each Delivery, Email, Topic, Audience can associate with more than one MainCourse?
    #1 - Correct - example: A course could be taught in a classroom setting or over Adobe connect. It can also cover multiple topics like - Sales & Forecasting
    #2 - Actually.... yes and no. A file either associates with one class, or lives by itself as a single piece of usable material.

    I found that using the following I am able to get close:

    (LIKE "*" &) in the query.
    The problem is... when I choose the first field (Topic) from the combo box... I get multiples of the associated records
    When I choose the second combo box field, it defines that a bit more
    When I choose the final field combo box it defines it to the file

    I need people to be able to choose one or all of the combo boxes and ensure they only receive ONE of each record.

  12. #12
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Supposing that they select settings from the combo boxes that can result in twelve different possible valid combinations. Do you care which one the user receives?

  13. #13
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Form 1 (Course Search) - Using three combo boxes, (Audience / Delivery / Topic) Allow the user to find the course(s) associated with any, or all of the three combo box choices.
    See Attached MDB. I only set up a form for searching for courses. The form for files would be similar.

    The search form is not up-datable because it is based on a union query.

    Is this closer???

  14. #14
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    ssanfu... this is close but it is working backwards.

    If I do a query by a topic.
    It should pull up each class that has that topic. (BUT only one version of the file based on the file name)

    If I ADD the audience query
    It should filter and pull up each class that has the topic AND also the corresponding audience. (BUT only one version of the file based on the file name)

    If I ADD the Delivery query
    It should filter and pull up each class that has the topic, audience AND the corresponding delivery. (BUT only one version of the file based on the file name)

    The problem is... duplicate records in the query.
    I do not want to get rid of the "duplicate entries", but I do want to remove them from the query results.

    What can I do in a query to limit the results to one record per unique field of my choosing?

    Thanks in advance for any help.

  15. #15
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    OK...
    Try this version.



    I made quite a bit of changes. I couldn't get the results you wanted with the structure you had. (Plus I am working without your data and examples)
    Look at the Relationship window.

    The form "frmFindcourses2" is to see/verify what courses are found. The form "frmResults" are what I think you want...??

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

Similar Threads

  1. How to query data from junction table?
    By bigal0043 in forum Queries
    Replies: 1
    Last Post: 05-24-2013, 03:03 AM
  2. Over 60 Days Query
    By sandy budd in forum Queries
    Replies: 13
    Last Post: 03-08-2012, 09:27 AM
  3. Replies: 4
    Last Post: 10-18-2011, 03:46 PM
  4. Date Lookup in Query for Junction Table
    By Phasma in forum Access
    Replies: 2
    Last Post: 01-21-2011, 03:36 PM
  5. Select Dates between days and two days ago?
    By rstonehouse in forum Queries
    Replies: 4
    Last Post: 08-18-2010, 02:13 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