Results 1 to 9 of 9
  1. #1
    nika.duncan is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    36

    Unable to generate correct report from query based on join properties

    Hey,

    I am struggling with a query to generate a report with the choice selection by each person. The issue I am having is that after selection if I used the "StaffMenuDetail" table to run the query the output for the choices are listed in numbers. When I add the other tables like the "ProteinChoices", "AppetizerChoice etc., what happen is that detail of data is reduced. The join or relationship is not able to produce the name of the choices because although "ProteinID" and "AppetizerID" is linked in the "StaffMenuDetail" it is not generating the name.

    Not sure how to generate the name as oppose but any help will be appreciated. Attached is a copy of the file been used. It is incomplete but I wanted to ensure that aspect is working before moving forward.

    Nika
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Which query? Don't see report object.
    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
    nika.duncan is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    36
    The query is "qryMenuChoosen", I haven't created the report as yet but was just running the query to see what is generated. When I start created the query and add the tables one by one starting with ""StaffMenuDetail" the record keeps reducing as I continue the join.

  4. #4
    Gicu's Avatar
    Gicu is online now VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    not looked at your file but you might want to use outer joins with the arrows pointing away from StaffMenuDetails.
    Cheers,
    Vlad

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I have looked at. The issue is beyond just changing the JOIN type. The query you have won't work. Joining WeekDay_Choice to every table is unnecessary. Just join it to StaffMenuDetail.

    Then change to RIGHT JOIN:

    SELECT AppetizerChoices.Appetizer, StaffMenuDetail.Branch, CarbChoices.CarbChoices, ProteinChoices.ProteinChoices, SideChoices.SideChoices, VegetableChoices.VegetableChoices, Staff_Listing.Staff_Name, WeekDay_Choice.WeekDays
    FROM WeekDay_Choice RIGHT JOIN (AppetizerChoices RIGHT JOIN (ProteinChoices RIGHT JOIN (VegetableChoices RIGHT JOIN (Staff_Listing RIGHT JOIN (CarbChoices RIGHT JOIN (SideChoices RIGHT JOIN StaffMenuDetail ON SideChoices.SideID = StaffMenuDetail.SideID) ON CarbChoices.CarbID = StaffMenuDetail.CarbID) ON Staff_Listing.Staff_UD = StaffMenuDetail.StaffNameID) ON VegetableChoices.VegetableID = StaffMenuDetail.VegetableID) ON ProteinChoices.ProteinID = StaffMenuDetail.ProteinID) ON AppetizerChoices.AppetizerID = StaffMenuDetail.AppetizerID) ON WeekDay_Choice.WeekDay_ID = StaffMenuDetail.WeekDayID;

    The query is creating the unnecessary joins and using INNER JOIN because they have been defined in Relationship Builder. You will have to manually adjust.
    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
    nika.duncan is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    36
    Hey,
    Thanks I have removed the relationship from WeekDay_Choice as stated and update query to read "RIGHT JOIN" as oppose to "INNER JOIN". It is generating the data now but when the "StaffMenuDetail" is checked when the data is inputted it is not updating the foreign keys "WeekDayID, AppetizerID,CarbID, ProteinID, SideID, and VegetableID" base on input. When I manually enter the data in those field based on input everything is displayed. I don't know how to fix that but once I am able to correct I will be able to generate the reports needed.

    Any help will be appreciated.

    Regards,
    Nika

  7. #7
    Gicu's Avatar
    Gicu is online now VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Nica,
    You have too sets of fields for the "choices" in your StaffMenuChoices table (i.e. AppetizerID and ApetizerChoice). Your combo boxes on the form are linked to the xxxChoice ones and they do populate. But your query user the first set (the xxxID). So you'll have to decide which ones you want to keep and act accordingly. You can modify the form to use the xxxID as control sources for the choice combos, or you can modify the query to use in your outer joins the xxxChoice instead of the xxxID fields.

    Cheers,
    Vlad

  8. #8
    Gicu's Avatar
    Gicu is online now VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Sorry, you have two sets of fields...

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Oops, I should have noticed that as well.

    Recommend you eliminate the text xxxChoice fields from StaffMenuDetails and change the comboboxes to save the xxxID. Also, should only save Staff_UD and remove StaffName and Branch fields.

    Since all the Choice tables are the same structure, really could be one table. Just have another field for the food category.

    If you don't show the weekday name in the combobox list, there is no need to include the WeekDay_Choice table. Instead of saving tons of query objects, can build SQL statement directly in RowSource and RecordSource properties.

    Staff name parts should be in separate fields: LastName, FirstName.
    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: 7
    Last Post: 11-02-2017, 01:44 PM
  2. Correct Query to generate a form
    By George in forum Access
    Replies: 5
    Last Post: 07-06-2016, 07:17 AM
  3. Replies: 5
    Last Post: 09-12-2014, 06:41 AM
  4. Replies: 0
    Last Post: 03-14-2011, 08:38 AM
  5. Returning correct rows in a join/nested query
    By goneaccessing in forum Queries
    Replies: 5
    Last Post: 03-03-2010, 12:21 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