Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Does not Like Query

Status
Not open for further replies.

gazza11

Technical User
Jan 12, 2003
46
0
0
AU
I have a table (Manhours) with 4 fields (ManID, VehicleID, Manhours and RptDate). I created the query (query 1) below (in Access 2000) to sum the total hours for each vehicle. It works OK in Access 2000.

This query is also used by an application written in VB6 (using Crystal Reports) to create a report. The report only has 2 fields (Vehicle and Total manhours). But when I run the report I get a "No data Found" message from Crystal.

Query 1
"SELECT Sum(manhours.Manhours) AS SumYearHours, Vehicles.Vehicle
FROM manhours INNER JOIN Vehicles ON manhours.VehicleID = Vehicles.VehicleID
WHERE (((manhours.RptDate) Like "*"))
GROUP BY Vehicles.Vehicle, manhours.VehicleID"


I also use the query below (in the same report).

Query 2
&quot;SELECT Sum(manhours.Manhours) AS SumYearHours, Vehicles.Vehicle FROM manhours INNER JOIN Vehicles ON manhours.VehicleID = Vehicles.VehicleID WHERE (manhours.rptDate >= #Format(DTShowStartDate, &quot;yyyy/mm/dd&quot;)# AND Manhours.rptDate <= #Format(DTShowEndDate, &quot;yyyy/mm/dd&quot;)#) GROUP BY Vehicles.Vehicle, manhours.VehicleID&quot;

This allows me to select start and end dates via a DTPicker in VB. This query works fine. Can someone please tell me why query 1 does not work with crystal - almost as if it does not like the &quot;*&quot;, but then how do I sum the hours. If I leave the &quot;(((manhours.RptDate) Like &quot;*&quot;))&quot; out of query1 I get a listing of individual entries in crystal. To me this confirms that the connection etc is working - only crystal does not like it when I include the dates.
 
This:

WHERE (((manhours.RptDate) Like &quot;*&quot;))

Is the same as having no Where clause, and if it's a real date field, should produce an error.

Remove the where clause.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top