Question How to query using one of two fields plus date

jmriddic

Registered User.
Local time
Today, 18:40
Joined
Sep 18, 2001
Messages
150
I set up a query originally to run by entering a employee name and a date range. I recently added another parameter to run it by employee id. I put that on the or line. Problem is that runs the query by the id field itself. I need to have it so I run it either:

ID and date range
Name and date range

The query is used as a basis of a report that totals check amounts for the date range. I was told of openargs but I am having trouble finding some good code examples of how to implement a form in conjunction with the report I already have.
 
Could you post the SQL version of the query?
 
Code

Here it is:

PARAMETERS [Type Name or hit ok to skip and run by Employee Number:] Text ( 255 ), [Employee Number:] Text ( 255 );
SELECT [CEAP Employees and Classes].Name, Sum([CEAP Employees and Classes].[Amount of Check]) AS [Total Amount]
FROM [CEAP Employees and Classes]
WHERE ((([CEAP Employees and Classes].Name)=[Type Name or hit ok to skip and run by Employee Number:]) AND (([CEAP Employees and Classes].[Date Check Issued]) Between [First Day of Month:] And ([Ending Day of Month:]))) OR ((([CEAP Employees and Classes].[Employee Number])=[Employee Number:]))
GROUP BY [CEAP Employees and Classes].Name;
 
Is this any good?
Code:
PARAMETERS [Type Name or hit ok to skip and run by Employee Number:] Text ( 255 ), [Employee Number:] Text ( 255 );
SELECT 
[CEAP Employees and Classes].Name, 
Sum([CEAP Employees and Classes].[Amount of Check]) AS [Total Amount]
FROM 
[CEAP Employees and Classes]
WHERE 
([CEAP Employees and Classes].Name =[Type Name or hit ok to skip and run by Employee Number:] AND [CEAP Employees and Classes].[Date Check Issued] Between [First Day of Month:] And [Ending Day of Month:]) OR 
([CEAP Employees and Classes].[Employee Number] = [Employee Number:] AND [CEAP Employees and Classes].[Date Check Issued] Between [First Day of Month:] And [Ending Day of Month:])
GROUP BY 
[CEAP Employees and Classes].Name;
 
Thanks

That solved my issue. Seems to work both ways now.
 
You're welcome.
Glad to help out.:)
 

Users who are viewing this thread

Back
Top Bottom