Les Isaacs
Registered User.
- Local time
- Today, 05:42
- Joined
- May 6, 2008
- Messages
- 186
Hi All
I am fairly new to using subqueries, but have been able to use some recently that have been very useful. I have now hit a problem though which I suspect is down to my inexperience with them
I had a main query with 2 subqueries, and a report based on the main query, and all was well. I then added a 3rd subquery to the main query, and still all was well - the main query ran perfectly (correctly returning the 3rd subquery field), and the report ran perfectly. I then added the 3rd subquery field to the report, and now the report won't open - I get "Multi-level GROUP BY clause is not allowed in a subquery".
What I don't get is that the main query with the new subquery field runs fine - the problem only occurs when I add that field to the report!
Hope someone can enlighten me. The sql of the main query is below, and the 3rd subquery field is 'AW8date'.
Many thanks
Les
The main query:
SELECT [qry x all staff].practice, (SELECT employee_submissions.submission_entered
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP - AW8" & "*"))) AS AW8date, Exists (SELECT employee_submissions.employee, employee_submissions.submission_type
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP - AW8" & "*"))) AS [AW8submitted?], Exists (SELECT employee_submissions.employee, employee_submissions.submission_type
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP SD55(E)" & "*"))) AS [SD55Esubmitted?], [qry x all staff].[ref order], [qry x all staff].nhsp_leaving_date, [qry x all staff].NHSP_updated_to
FROM [qry x all staff]
WHERE ((([qry x all staff].practice)<>"The Colours Practice") AND (((SELECT employee_submissions.submission_entered
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP - AW8" & "*"))))=True) AND ((Exists (SELECT employee_submissions.employee, employee_submissions.submission_type
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP - AW8" & "*"))))=True) AND ((Exists (SELECT employee_submissions.employee, employee_submissions.submission_type
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP SD55(E)" & "*"))))=False) AND (([qry x all staff].[ref order])=3 Or ([qry x all staff].[ref order])=4) AND (([qry x all staff].nhsp_leaving_date)>#3/31/2012#) AND (([qry x all staff].NHSP_updated_to)=CDate("31 March " & Right([forms]![frm x main]![year],4)-1)));
I am fairly new to using subqueries, but have been able to use some recently that have been very useful. I have now hit a problem though which I suspect is down to my inexperience with them
I had a main query with 2 subqueries, and a report based on the main query, and all was well. I then added a 3rd subquery to the main query, and still all was well - the main query ran perfectly (correctly returning the 3rd subquery field), and the report ran perfectly. I then added the 3rd subquery field to the report, and now the report won't open - I get "Multi-level GROUP BY clause is not allowed in a subquery".
What I don't get is that the main query with the new subquery field runs fine - the problem only occurs when I add that field to the report!
Hope someone can enlighten me. The sql of the main query is below, and the 3rd subquery field is 'AW8date'.
Many thanks
Les
The main query:
SELECT [qry x all staff].practice, (SELECT employee_submissions.submission_entered
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP - AW8" & "*"))) AS AW8date, Exists (SELECT employee_submissions.employee, employee_submissions.submission_type
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP - AW8" & "*"))) AS [AW8submitted?], Exists (SELECT employee_submissions.employee, employee_submissions.submission_type
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP SD55(E)" & "*"))) AS [SD55Esubmitted?], [qry x all staff].[ref order], [qry x all staff].nhsp_leaving_date, [qry x all staff].NHSP_updated_to
FROM [qry x all staff]
WHERE ((([qry x all staff].practice)<>"The Colours Practice") AND (((SELECT employee_submissions.submission_entered
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP - AW8" & "*"))))=True) AND ((Exists (SELECT employee_submissions.employee, employee_submissions.submission_type
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP - AW8" & "*"))))=True) AND ((Exists (SELECT employee_submissions.employee, employee_submissions.submission_type
FROM employee_submissions
WHERE (((employee_submissions.employee)=[qry x all staff].staff_name) AND ((employee_submissions.submission_type) like "NHSP SD55(E)" & "*"))))=False) AND (([qry x all staff].[ref order])=3 Or ([qry x all staff].[ref order])=4) AND (([qry x all staff].nhsp_leaving_date)>#3/31/2012#) AND (([qry x all staff].NHSP_updated_to)=CDate("31 March " & Right([forms]![frm x main]![year],4)-1)));