Results 1 to 10 of 10
  1. #1
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28

    I want to make a query on three tables, with dates and activities but one table is duplicating

    Hi I have three tables that hold similar information, for example Client ID, Date.

    One of the tables shows client information, another shows how many times a client comes into the establishment and uses certain services, the last one shows whether a client stayed successfully overnight.

    I want to build a report which counts each service a client has had during the day using date parameters and how many times during that parameter they stayed overnight.



    I have built a query, which counts the services by date parameter, but it duplicates the number of times the client has stayed overnight (e.g., client came in on 1/7/18 and 2/7/18 but only stayed overnight on 2/7/18 - query shows two of the latter records).

    Can someone please tell me what I'm doing wrong?

    Kelly

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Are you joining the 3 tables? Do you have a database you can link or screenshots?

  3. #3
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    Click image for larger version. 

Name:	Query Screen Shot 1.jpg 
Views:	9 
Size:	149.0 KB 
ID:	34618Click image for larger version. 

Name:	Query Screen Shot 1.jpg 
Views:	9 
Size:	149.0 KB 
ID:	34618
    So - you can see there's the other date from the last table.... this is the one that duplicates

  4. #4
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    Sorry - duplicated the screen shots....

    Click image for larger version. 

Name:	Query Screen Shot 2.jpg 
Views:	10 
Size:	149.3 KB 
ID:	34619

  5. #5
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Hard to see, but im thinking you dont need the join for the data between activity log sheet and client.

  6. #6
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Can you right click the designer and copy the SQL for here?

  7. #7
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    Sorry - I'm a novice - how do I do that for you?

  8. #8
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    on the top left of your screen where it says "view" and "run". Under that view is a arrow, click that and choose SQL

  9. #9
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    SELECT Client.[Client Reference], [Activity Log Sheet].[Enter Date], [Activity Log Sheet].[Advice and Advocacy], [Activity Log Sheet].[Meal Ticket B], [Activity Log Sheet].[Meal Ticket L], [Activity Log Sheet].[Mental Health], [Activity Log Sheet].[Phone Use], [Activity Log Sheet].Post, [Activity Log Sheet].Internet, [Activity Log Sheet].Shower, [Activity Log Sheet].[Washing Machine], [Daily Log Sheet].[Enter Date], [Daily Log Sheet].[Offered a Place for that night], [Daily Log Sheet].[Accepted Place for that Night], [Daily Log Sheet].[Arrived at 5/6pm], [Daily Log Sheet].[Granted Access that Evening], [Daily Log Sheet].[Asked to Leave Once In], [Daily Log Sheet].[Client Walked Out]
    FROM ([Daily Log Sheet] INNER JOIN Client ON [Daily Log Sheet].[Client ID] = Client.[Client Reference]) INNER JOIN [Activity Log Sheet] ON [Daily Log Sheet].[Client ID] = [Activity Log Sheet].[Client ID]
    WHERE (((Client.[Client Reference])=[Please enter Client Reference]) AND (([Activity Log Sheet].[Enter Date]) Between [Please enter first date] And [Please enter last date]));

  10. #10
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    When you press F4 while in the designer, it should bring up the properties dialog. A Kludge may be to set the unique records, value to true.


    separate solution

    I can't tell which join is referencing the data on the one to many from here. Looks like you need to click the line that connects the activity log and the client. and press delete.then run again.

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

Similar Threads

  1. Replies: 4
    Last Post: 03-08-2018, 03:27 PM
  2. Replies: 2
    Last Post: 02-17-2015, 01:01 PM
  3. Replies: 5
    Last Post: 07-12-2014, 02:55 PM
  4. Query two tables for specified dates
    By funkygoorilla in forum Queries
    Replies: 2
    Last Post: 12-12-2011, 11:12 AM
  5. Time Spent on Activities Report
    By avarusbrightfyre in forum Reports
    Replies: 1
    Last Post: 10-14-2010, 05:02 PM

Tags for this Thread

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