Link to home
Start Free TrialLog in
Avatar of Marc_Fortin
Marc_Fortin

asked on

Data report grouping

Hi,

I have created a Data Report using the Data Report Designer.

The recordsource for the report is coded into the application using the following

rstRapport.Open "SELECT Lot.LotID, Lot.LotNom,Echantillon.EchantillonRefClientID,Echantillon.EchantillonDateEntree, Echantillon.EchantillonDateSortie, Echantillon.ModeSortie, Echantillon.EchantillonNom, Echantillon.EchantillonLongueur, Echantillon.EchantillonLargeur, Echantillon.EchantillonEpaisseur, Echantillon.EchantillonMateriau, Echantillon.EchantillonMagnetise, Echantillon.EchantillonSystemeMetric, Echantillon.EchantillonCommentaire, Type.TypeNom, ZoneEchantillon.ZoneNom, Defaut.DefautNom, Defaut.DefautLocalisation, Defaut.DefautLongueur, Defaut.DefautLargeur, Defaut.DefautProfondeur, Defaut.TypeDefaut, Echantillon.EchantillonID FROM ZoneEchantillon INNER JOIN (Type INNER JOIN (Lot INNER JOIN (Echantillon INNER JOIN Defaut ON Echantillon.EchantillonID = Defaut.EchantillonID) ON Lot.LotID = Echantillon.LotID) ON Type.TypeID = Echantillon.TypeID) ON ZoneEchantillon.ZoneID = Echantillon.ZoneID WHERE Lot.LotID = rstEchantillon.Fields("LotID").Value, cnn, adOpenKeyset, adLockOptimistic, adCmdText
 
' Connect the Recordset to the DataReport.
Set rptReport.DataSource = rstRapport

There is no problem with this and it works as it should, however what I need to be able to do is to add a Group Header/Footer into the report and have the data grouped on the "EchantillonNom" field of the SQL. If I do this then I get an error saying that "Report Sections do not match data source".

How can I get this to work?

Note that if I use a Data Environment object to product the group data and add the Data Environment as the recordsource for the report then I can get it to work. But I really would like to do it in code

Any help appreciated thanks
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial