Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    Bilakos93 is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2023
    Posts
    12

    db.zip
    There you go

  2. #17
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi

    Well yet again your relationships are all wrong (see attached)

    1. All tables should have a PK - Autonumber with a name other than just "ID"
    2. Your table "tblStudents" has a primary key set on the field "agm" which has a DataType of Number set as Double
    3. Your table "tblStuDiag" has a PK ste as "ID" whcih should be named "StuDiagID"
    4. Your table "tblStuDiag" has a field named "Student" which is set as a Lookup Field. You need to Google "The Evils of Lookup Fields in Access Tables"
    5. Your table "tblStuDiag" has field named "Diagnosis" with a DataType of Text, which is set as a Lookup Field. You need to Google "The Evils of Lookup Fields in Access Tables"
    Attached Thumbnails Attached Thumbnails RI.png  
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  3. #18
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    All that is moot ATM?
    I would just get the query working before you start grouping, small steps

    However I cannot get the query to recognise your report date for either criteria?
    Edt: That was likely due to that other query perhaps?

    Code:
    SELECT students_rep.lname, students_rep.fname, students_rep.agm, tblStudDiag.diagnosis.Value, tblStudDiag.duration, DateAdd("d",duration-1,StartDate) AS EndDate, students_rep.nd_dsls & " " & students_rep.taksi AS Class, forms!dailyreportdate!rdate AS reportdate, DateAdd("d",[duration]-1,[StartDate]) AS Expr1
    FROM students_rep INNER JOIN tblStudDiag ON students_rep.agm = tblStudDiag.student
    WHERE tblStudDiag.StartDate)<=[Forms]![dailyreportdate]![rdate] AND DateAdd("d",[duration]-1,[StartDate])>=[Forms]![dailyreportdate]![rdate];
    I honestly do not know what you have done, as I created a new form with a date control and referred to that, removed the formcontrol you had as a table field, and yet it still prompts for reportdate!rdate ??
    OK, found it in the other query.
    Code:
    SELECT students_rep.lname, students_rep.fname, students_rep.agm, tblStudDiag.diagnosis.Value, tblStudDiag.duration, DateAdd("d",duration-1,StartDate) AS EndDate, students_rep.nd_dsls & " " & students_rep.taksi AS Class,  DateAdd("d",[duration]-1,[StartDate]) AS Expr1
    FROM students_rep INNER JOIN tblStudDiag ON students_rep.agm=tblStudDiag.student
    WHERE tblStudDiag.StartDate<=[Forms]![form1]![rdate];

    I get two records with a date of 12/09/2023
    No idea if that is correct or not, even with the AND ?
    AGM 00171 and 03877 are the two records produced, but query is slow as hell due to that first query?, even on an SSD.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #19
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    looks like your form is corrupted. This works for me

    Code:
    SELECT students_rep.lname, students_rep.fname, students_rep.agm, tblStudDiag.diagnosis.Value, tblStudDiag.StartDate, tblStudDiag.duration, DateAdd("d",duration-1,StartDate) AS EndDate, students_rep.nd_dsls & " " & students_rep.taksi AS Class, [forms]![form1]![rdate] AS reportdate
    FROM students_rep INNER JOIN tblStudDiag ON students_rep.agm = tblStudDiag.student
    WHERE (((CDate([forms]![form1]![rdate])) Between [StartDate] And DateAdd("d",[duration]-1,[startdate])))
    GROUP BY students_rep.lname, students_rep.fname, students_rep.agm, tblStudDiag.diagnosis.Value, tblStudDiag.StartDate, tblStudDiag.duration, DateAdd("d",duration-1,StartDate), students_rep.nd_dsls & " " & students_rep.taksi, [forms]![form1]![rdate], DateAdd("d",[tblStudDiag].[duration]-1,[tblStudDiag].[startdate]), forms!form1!rdate;
    I created a new form (called Form1) and populated with a single control called rDate - also had to modify your other query to use the new form as well

  5. #20
    Bilakos93 is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2023
    Posts
    12
    dailyreportdate!rdate is also used for the query students_rep , that's probably why

    All the entries are from 12th Sep onwards , so not sure, I'll have a look in a moment

  6. #21
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    If you are responding to me, read the whole post

  7. #22
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Quote Originally Posted by CJ_London View Post
    If you are responding to me, read the whole post
    Probably me CJ, as it took me a while to find the prompt reason.
    However when I use my Form1 in both queries, I do not get the prompt and the query runs presenting two entries.

    I got rid of all the Group By to just make a simple select.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #23
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    using a date of 13/9/2023 I got around 10. But now deleted all from my pc so can't verify

  9. #24
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    think the OP only responds to the post they get advised about, doesn't see the rest

  10. #25
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Quote Originally Posted by CJ_London View Post
    using a date of 13/9/2023 I got around 10. But now deleted all from my pc so can't verify
    I get 13, however I removed the group by.
    Attached Thumbnails Attached Thumbnails Capture.JPG  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #26
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,474
    To Troubleshoot: Take out the first part of the Where "[tblStudDiag].[StartDate]<=forms!dailyreportdate!rdate and" and see if it works with the last part. Also can test with replacing [tblStudDiag.duration]-1 with an actual number and see if it works, etc. Replace the !rDate with actual date and see if it works. Do all these one at a time to pinpoint where the issue is.


Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 06-01-2023, 12:16 PM
  2. Return values from yesterday date
    By pvl55 in forum Queries
    Replies: 2
    Last Post: 08-25-2021, 11:36 AM
  3. Replies: 6
    Last Post: 08-09-2018, 11:41 PM
  4. Replies: 3
    Last Post: 10-30-2016, 05:50 AM
  5. Replies: 3
    Last Post: 06-02-2014, 10:41 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