Remove prompt while running report

knn9413

Registered User.
Local time
Yesterday, 17:49
Joined
Feb 18, 2015
Messages
36
I have a report that is created from the following query (qryTotalProjectHours). What I am trying to do is get the total hours spent on Tasks within a given time period. A given Task can we worked on by multiple individuals and hence I need to find a way to aggregate the hours spent.

Code:
SELECT TasksEntries.Project, TasksEntries.Task, Sum(TimeTracker.WorkHours) AS TotalHours
FROM TasksEntries INNER JOIN TimeTracker 
ON (TasksEntries.EmployeeId = TimeTracker.EmployeeId) AND (TasksEntries.TaskID = TimeTracker.TaskId)
GROUP BY TasksEntries.Project, TasksEntries.Task;

I accept the start and end dates in a form and pass it like shown below. WorkDate is a column in the TimeTracker table and is not present in any other table.

Code:
strWhere = "WorkDate BETWEEN #" & txtMgrRptStartDate & "# AND #" & txtMgrRptEndDate & "#"
DoCmd.OpenReport "rptTotalProjectHours", acViewPreview, "qryTotalProjectHours", strWhere, acWindowNormal

When the report is invoked, I get a box where it says
"Enter parameter value" for Workdate..

Is there anyway I can get rid of the prompt? I never thought you needed the column name in the SELECT statement to be able to run this.

I should add the I tried the query with the WorkDate hardcoded in there and it worked fine and returned the correct results
 
Last edited:
Is there a way to check what the query looks like before it opens up the report? If so, can someone please guide me how to look into it?
 
Is there a way to check what the query looks like before it opens up the report?
What exactly do you mean - the result, the SQL-String or ???
 
...
I should add the I tried the query with the WorkDate hardcoded in there and it worked fine and returned the correct results
How does it looks like when you hardcode it and how does it looks like when you are applying the values to the strWhere?
Try to compare it using "Debug.Print strWhere"!
 
How does it looks like when you hardcode it and how does it looks like when you are applying the values to the strWhere?
Try to compare it using "Debug.Print strWhere"!

I did debug the code, it looks good to me. See the contents of WorkDate below. The "#" sign works everywhere else so I believe that should be ok

Code:
strWhere : "WorkDate BETWEEN #4/1/2015# AND #4/30/2015#" : String : Form_frmManagerReport.cmdRunRpt_Click
 

Users who are viewing this thread

Back
Top Bottom