hi everyone
can you give an example of coding in vb.net vs2010 how to make a report in crystal report 2013 with sub report

thanks for advanced

@xrjf can you give a link how to display sub report on crystal 2013 step by step in vb.net programming language on vs2010.

best regards

Hi @xrjf
i tried to display crystal report 2013 on vb.net but why the result is empty.
sample program is in the file attachment

thanks for advanced

Try:

rpt.SetDataSource(ds.Tables(0))
rpt.Subreports("YourSubreport.rpt").SetDataSource(ds.Tables(1))

I ment:

  rpt.SetDataSource(ds.Tables(0))
  rpt.Subreports("YourSubreport.rpt").SetDataSource(ds_detspk.Tables(0))

Hi @xrjf
when my program runs on the statement "rpt.SetDataSource(ds.Tables(0))"
there is an error "Column 'KODE_WAR' does not allow nulls."
after I check the DAFTAR_WARNA table or the SPK table, the KODE_WAR field is all filled, there is no Null data.

Query "SELECT NOSPK, TGL_SPK , NAMA_GREY, SPK.KODE_WAR, NAMA_WAR, ROLL_PROD_SPK , KG_PROD_SPK ,KET_SPK
FROM SPK
INNER JOIN GRAY ON SPK.CODE_GREY = GRAY.CODE_GREY
INNER JOIN DAFTAR_WARNA ON SPK.KODE_WAR =DAFTAR_WARNA.KODE_WAR
WHERE nospk = 'PKP-00001' "
I run SQLQuery in SQL Manager, the output record appears.

What is this problem caused by?

thanks for advanced

hi xrjf

error problem "Column 'CODE_WAR' does not allow nulls." it's been solved,
it turns out that in the "master dataset" the default KODE_WAR field cannot contain <DBNull>
but there is a new problem with
rpt.Subreports("MySubReport.rpt").SetDataSource(ds_detspk.Tables(0))
new error appears
"Object reference is not set to an instance of an object."

thanks for advanced

Of course, 'MySubReport.rpt' in rpt.Subreports("MySubReport.rpt").SetDataSource(ds_detspk.Tables(0)) should be replaced by the name you have given to your subreport.

'MySubReport.rpt' in rpt.Subreport("MySubReport.rpt").SetDataSource(ds detspk.Tables(0))
is the name of the subreport that I created in the crystal report with the name "CryRpt_SPK.rpt" as defined in

Dim rpt As New CryRpt_SPK() 'The report created.
                            'Crystal report which contains the master and details which to display the details 
                            'are made in the subreport

Hi @xrjf
apparently the problem is for the error "Object reference not set to an instance of an object." , is caused by the name of the subreport followed by the suffix RPT

The correct writing is as follows:

    rpt.Subreports("YourSubreport").SetDataSource(ds_detspk) 'without extension rpt

Thank you for your attention and response

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.