Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / December 2004



Tip: Looking for answers? Try searching our database.

Data Report Designer and SHAPE command

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim - 30 Dec 2004 22:49 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.