I have a database to track the documents our company's Quality Department uses. The documents are kept in one table, and the revision information for the documents are kept in another (many revisions to one document). I need to be able to display the following on a form:
*All the documents for a department.
*The latest revision for each document.
*All the documents each document calls.
*The latest revision for each document called.
I have a datasheet view subform on the department form that shows all of the documents, along with their revisions. This subform then has another datasheet view subform which shows all of the documents each document calls, along with their revisions. At this point, these two subforms will show multiple entries for every document that has had multiple revisions. I need to weed it down to only the latest revisions.
I have tried to write a query that orders by the Rev field, descending, and then selects all of the document information for only the Top 1 of the result. This works fine, but it gives me exactly 1 entry out of the entire database. When I try to add a "Group by" to the SQL, the select statement no longer works.
Here is an example of what I am trying:
SELECT TOP 1 Revisions.revDoc, Revisions.Rev, Revisions.revDate, Revisions.revWhy, Documents.Doc, Documents.DocType, Documents.Name, Documents.File, Documents.FileType
FROM Documents INNER JOIN Revisions ON Documents.Doc = Revisions.revDoc
ORDER BY Revisions.Rev DESC,
GROUP BY [Revisions].[revDoc];
With this select statement, I get this error message:
Syntax error (missing operator) in query expression "GROUP BY [Revisions].[revDoc]"
The query works fine if I remove the GROUP BY line, but only gives me 1 item out of the entire database. In the subform, the result is that only that one document will show any revision information.
If I make the revision information into a subform, then there will be a conflict with the existing subform, which shows the documents atht each document calls.
Does anyone have any suggestions or tips? Is there another way to write the select statement?
Cheryl dc Kern
*All the documents for a department.
*The latest revision for each document.
*All the documents each document calls.
*The latest revision for each document called.
I have a datasheet view subform on the department form that shows all of the documents, along with their revisions. This subform then has another datasheet view subform which shows all of the documents each document calls, along with their revisions. At this point, these two subforms will show multiple entries for every document that has had multiple revisions. I need to weed it down to only the latest revisions.
I have tried to write a query that orders by the Rev field, descending, and then selects all of the document information for only the Top 1 of the result. This works fine, but it gives me exactly 1 entry out of the entire database. When I try to add a "Group by" to the SQL, the select statement no longer works.
Here is an example of what I am trying:
SELECT TOP 1 Revisions.revDoc, Revisions.Rev, Revisions.revDate, Revisions.revWhy, Documents.Doc, Documents.DocType, Documents.Name, Documents.File, Documents.FileType
FROM Documents INNER JOIN Revisions ON Documents.Doc = Revisions.revDoc
ORDER BY Revisions.Rev DESC,
GROUP BY [Revisions].[revDoc];
With this select statement, I get this error message:
Syntax error (missing operator) in query expression "GROUP BY [Revisions].[revDoc]"
The query works fine if I remove the GROUP BY line, but only gives me 1 item out of the entire database. In the subform, the result is that only that one document will show any revision information.
If I make the revision information into a subform, then there will be a conflict with the existing subform, which shows the documents atht each document calls.
Does anyone have any suggestions or tips? Is there another way to write the select statement?
Cheryl dc Kern