Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: dataset in subreport Post Reply Post New Topic
Author Message
jviure
Newbie
Newbie


Joined: 27 Aug 2010
Online Status: Offline
Posts: 2
Quote jviure Replybullet Topic: dataset in subreport
     Posted: 27 Aug 2010 at 11:49pm
Hi people! this is my first post! I am starting with crystal reports and I find it perfect! I have a report that show purchases lines but under every purchase line there are one or many articles (I've make a subreport). The problem is that I don't see the subreport, is blank! and I think that I am passing correctly the parameter and setting the datasets correctly, here is my code:

DataSet ds = BBDDadapter.executeWithResult("SELECT a.id, c.nombre,c.apellidos,t.nombre,a.data,a.importe,a.forma_pago FROM albaran a LEFT JOIN trabajadores t ON t.id=a.trabajador_id LEFT JOIN clientes c ON c.id=a.cliente_id");

ReportAlbaranes rp = new ReportAlbaranes();
rp.SetDataSource(ds.Tables[0]);

DataSet ds1 = BBDDadapter.executeWithResult("SELECT * FROM albaran_item");
rp.Subreports[0].SetDataSource(ds1.Tables[0]);
crystalReportViewer1.ReportSource = rp;


Is there something strange? the sql's are all ok (I've checked them).  My subreport link I think is ok, here is an screenshot:

http://img844.imageshack.us/img844/6448/pant.png

A last thing, I've inserted the parameter ?Pm-albaran.id in the subreport and seems ok when showing the report so the parameter I think is passing ok. http://img826.imageshack.us/img826/4899/pant2.png

Well, tell me something please, thanks a lot! :)

George

p.d: I don't know why the parameter , the PK, is showing with 2 decimals in the main report and in the subreport (well, in the main report I've changed the format as you can see), the PK is of "Type:Number"


Edited by jviure - 27 Aug 2010 at 11:58pm
IP IP Logged
jviure
Newbie
Newbie


Joined: 27 Aug 2010
Online Status: Offline
Posts: 2
Quote jviure Replybullet Posted: 28 Aug 2010 at 5:39am
Hi again, I have notices! the problem is in the Dataset ds1 I think or in the formula field I use. In the table albaran_item I've one column that tell me the type of the item, if it is a Product or a Service.
In the subreport I want to show the name of the Product OR the name of the Service depending of the column type.
So I've a Formula field that does:

 if {albaran_item.tipo}=1 then
    {productos.nombre}
else
    {servicios.nombre}


and the dataset ds1 now is:

SELECT ai.*,p.nombre,s.nombre FROM albaran_item ai LEFT JOIN productos p ON p.id=ai.item_id LEFT JOIN servicios s ON s.id=ai.item_id

And the problem is in the formula field! if I try to execute the Formula I show you I receive a blank subreport but if I do:

 if {albaran_item.tipo}=1 then
    "Product"
else
    "Service"


It goes perfect but I want the name of the product or of the service, you know?

Thanks!


Edited by jviure - 28 Aug 2010 at 5:41am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum