Max Query

T

TitaniaTiO2

I am trying to use the following Query

SELECT tblTraining.PersonID, tblTraining.DocumentNumber,
tblDocument.DocumentTitle, tblTraining.EmployeeDocumentStatus,
tblTraining.TrainingStatus, Max(tblTraining.HistoryTrainedTo) AS
MaxHistoryTrainedTo, tblDocument.DocumentLifeCycle
FROM tblDocument INNER JOIN tblTraining ON tblDocument.DocumentNumber =
tblTraining.DocumentNumber
GROUP BY tblTraining.PersonID, tblTraining.DocumentNumber,
tblDocument.DocumentTitle, tblTraining.EmployeeDocumentStatus,
tblTraining.TrainingStatus, tblDocument.DocumentLifeCycle
HAVING
(((tblTraining.PersonID)=[Forms]![frmEditEmployeeInformation]![txtPersonID])
AND ((tblDocument.DocumentLifeCycle)="Active"));


I want the query to display ONLY the Max HistoryTrainedTo Number for each
document and allow me to edit some fields.

Right now the query displays all histories trained to and will not allow me
to edit any fields.

Any suggestions on how I can proceed?

Thanks

Titania
 
K

KARL DEWEY

As the old saying goes, 'You can not have your cake and eat it too.'
You need to use a totals query to pull the tblTraining.DocumentNumber and
Max(tblTraining.HistoryTrainedTo) AS MaxHistoryTrainedTo only.
Then join that query in a select (not totals) on the
tblTraining.DocumentNumber.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top