I am creating a DataReport using the Data Report Designer (VB6) and using
the following SHAPE command to create a hierarchical recordset of
Client/FoodService records:
mstrSQL = "SHAPE {SELECT * FROM Client} AS Client " & _
"APPEND ({SELECT FoodService.FoodServiceID, " & _
"FoodService.ClientID, " & _
"FoodService.FoodServiceDate, " & _
"FoodServiceTypes.FoodServiceTypeDescription,
" & _
"FoodService.NumberOfBags, " & _
"FoodService.Comments FROM
FoodService " & _
"LEFT JOIN FoodServiceTypes ON
FoodService.FoodServiceTypeID=FoodServiceTypes.FoodServiceTypeID " & _
"WHERE FoodService.FoodServiceDate Between
#" & mstrStartDate & "# And #" & mstrEndDate & "# " & _
"ORDER BY FoodService.FoodServiceDate} AS
FoodService " & _
"RELATE ClientID TO ClientID) AS FoodService"
Currently, the report prints every client record whether or not there have
been any 'FoodServiceRecords' filed for that client. How can print only
those clients that have at least one FoodServiceRecord on file for the date
range specified? I guess I could loop through the recordset and delete those
client records with no child records, but is there something I can add to
the SHAPE command to do this?
Tim
Tim - 31 Dec 2004 17:20 GMT
I answered my own question. I added the 'SUM(FoodService.NumberOfBags) As
TotalBags' to the SHAPE command below, opened the recordset, then filtered
the recordset on 'TotalBags <> 0'. I would still be interested to know if
there is way to do this all in the SHAPE command.
mstrSQL = "SHAPE {" & strNewValue & "} AS rsClient " & _
"APPEND ({SELECT FoodService.FoodServiceID, " & _
"FoodService.ClientID, " & _
"FoodService.FoodServiceDate, " & _
"FoodServiceTypes.FoodServiceTypeDescription,
" & _
"FoodService.NumberOfBags, " & _
"FoodService.Comments FROM FoodService "
& _
"LEFT JOIN FoodServiceTypes ON
FoodService.FoodServiceTypeID=FoodServiceTypes.FoodServiceTypeID " & _
"WHERE FoodService.FoodServiceDate Between #" &
mstrStartDate & "# And #" & mstrEndDate & "# " & _
"ORDER BY FoodService.FoodServiceDate} AS
rsDetail " & _
"RELATE ClientID TO ClientID) AS FoodService, " & _
"SUM(FoodService.NumberOfBags) As TotalBags"
Set madoRS = New RecordSet
madoRS.Open mstrSQL, mdbConnection, adOpenStatic, adLockReadOnly,
adCmdText
'Filter out clients with no bags.
madoRS.Filter = "TotalBags <> 0"
>I am creating a DataReport using the Data Report Designer (VB6) and using
>the following SHAPE command to create a hierarchical recordset of
[quoted text clipped - 25 lines]
>
> Tim