Query Problem - Two or More Records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to run a query where I can determine when an employee gets more
than 2 complaints within a certain date range.

The fields in my query are:

IncidentDate
EmployeeNumber

In the INCIDENTDATE column, I set the criteria as:

Between [Forms]!frmEmployeeComplaintDialogBox]![BeginningDate] And
[Forms]!frmEmployeeComplaintDialogBox]![EndingDate]

In the EMPLOYEENUMBER column, I set the criteria as:

In (SELECT[EmployeeNumber] FROM [tblECDEmployeeInvolved] WHERE
[EmployeeNumber] > 2 GROUP BY [EmployeeNumber] HAVING Count (*) > 2)

I am not getting a correct response. I am showing employees that have two or
more complaints but not just within the specified date range.

Any help would be greatly appreciated.

Thank you in advance for your response.

Rick
 
Try changing the sub-query in the criteria to

In (SELECT [EmployeeNumber]
FROM [tblECDEmployeeInvolved]
WHERE [IncidentDate] Between
[Forms]!frmEmployeeComplaintDialogBox]![BeginningDate]
And [Forms]!frmEmployeeComplaintDialogBox]![EndingDate]
GROUP BY [EmployeeNumber] HAVING Count (*) > 2)

This returns records where the employee had MORE than 2 incidents in the
specified time frame.

Your sub-query was returning any employee that had an employee number
greater than 2 and had more than 2 incidents in the entire table.
 
John,

I am still getting the same problem.

I did neglect to say in my first posting that the INCIDENTDATE is in a
different table.

INCIDENTDATE is in the tblINCIDENTINFORMATION table

EMPLOYEENUMBER is in the tblECDEMPLOYEEINVOLVED table

I tried using your suggested statement in both the INCIDENTDATE criteria and
the EMPLOYEENUMBER criteria.

Thanks for your help...

Rick




John Spencer said:
Try changing the sub-query in the criteria to

In (SELECT [EmployeeNumber]
FROM [tblECDEmployeeInvolved]
WHERE [IncidentDate] Between
[Forms]!frmEmployeeComplaintDialogBox]![BeginningDate]
And [Forms]!frmEmployeeComplaintDialogBox]![EndingDate]
GROUP BY [EmployeeNumber] HAVING Count (*) > 2)

This returns records where the employee had MORE than 2 incidents in the
specified time frame.

Your sub-query was returning any employee that had an employee number
greater than 2 and had more than 2 incidents in the entire table.


Rick_C said:
I am trying to run a query where I can determine when an employee gets more
than 2 complaints within a certain date range.

The fields in my query are:

IncidentDate
EmployeeNumber

In the INCIDENTDATE column, I set the criteria as:

Between [Forms]!frmEmployeeComplaintDialogBox]![BeginningDate] And
[Forms]!frmEmployeeComplaintDialogBox]![EndingDate]

In the EMPLOYEENUMBER column, I set the criteria as:

In (SELECT[EmployeeNumber] FROM [tblECDEmployeeInvolved] WHERE
[EmployeeNumber] > 2 GROUP BY [EmployeeNumber] HAVING Count (*) > 2)

I am not getting a correct response. I am showing employees that have two
or
more complaints but not just within the specified date range.

Any help would be greatly appreciated.

Thank you in advance for your response.

Rick
 
Please copy and post the SQL of your query.

(Possibly unneeded instructions follow)
Open the query
Select View:Sql from the Menu
Select all the text
Copy it
Paste it into the message


Rick_C said:
John,

I am still getting the same problem.

I did neglect to say in my first posting that the INCIDENTDATE is in a
different table.

INCIDENTDATE is in the tblINCIDENTINFORMATION table

EMPLOYEENUMBER is in the tblECDEMPLOYEEINVOLVED table

I tried using your suggested statement in both the INCIDENTDATE criteria
and
the EMPLOYEENUMBER criteria.

Thanks for your help...

Rick




John Spencer said:
Try changing the sub-query in the criteria to

In (SELECT [EmployeeNumber]
FROM [tblECDEmployeeInvolved]
WHERE [IncidentDate] Between
[Forms]!frmEmployeeComplaintDialogBox]![BeginningDate]
And [Forms]!frmEmployeeComplaintDialogBox]![EndingDate]
GROUP BY [EmployeeNumber] HAVING Count (*) > 2)

This returns records where the employee had MORE than 2 incidents in the
specified time frame.

Your sub-query was returning any employee that had an employee number
greater than 2 and had more than 2 incidents in the entire table.


Rick_C said:
I am trying to run a query where I can determine when an employee gets
more
than 2 complaints within a certain date range.

The fields in my query are:

IncidentDate
EmployeeNumber

In the INCIDENTDATE column, I set the criteria as:

Between [Forms]!frmEmployeeComplaintDialogBox]![BeginningDate] And
[Forms]!frmEmployeeComplaintDialogBox]![EndingDate]

In the EMPLOYEENUMBER column, I set the criteria as:

In (SELECT[EmployeeNumber] FROM [tblECDEmployeeInvolved] WHERE
[EmployeeNumber] > 2 GROUP BY [EmployeeNumber] HAVING Count (*) > 2)

I am not getting a correct response. I am showing employees that have
two
or
more complaints but not just within the specified date range.

Any help would be greatly appreciated.

Thank you in advance for your response.

Rick
 

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

Back
Top