Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
Hello, i am working with crystal report. I want to do the crystal report's title dynamically with the usage of coding not static in the vb.net. the report title should be dynamic means if I have selected from combo and I want to show that selected item in the report title and some text also , it should be display in the crystal report title. i had selected item from combo is "AHMEDABAD".
i want to display Report Title as below.
        Report Of Ahmedabad City
Posted
Updated 23-Mar-12 22:42pm
v3

hi Dipak.
u can use "Report Title" or "Report Comments" Or "File Author" Field in Special Fields Section of Crystal Report Designer and place them title section of your crystal report and set values of these fields in coding as shown example

VB
Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
       Me.ViewReceiptTableAdapter.Connection = Connection
       Me.ViewReceiptTableAdapter.FillByDate(Me.DSetFeeReports.ViewReceipt, Me.DtDate.Value)
       CryDailyCollection1.SummaryInfo.ReportTitle = " Report Of " & ComboCity.text & "City"
       CryDailyCollection1.SetDataSource(Me.DSetFeeReports)

       Me.CrystalReportViewer1.ReportSource = CryDailyCollection1

   End SubEnd SubEnd Subtion1

   End Sub


i hope this solve your problem
 
Share this answer
 
Dim RPTTITLE As String

Try
Dim tmp As String

If ddlactive.SelectedItem.Text = "Yes" Then
tmp = "Y"

ds1 = con.FetchData("select * from computer_mast where type='" & ddlOpt.SelectedItem.Text & "' and active='" & tmp & "' order by deptname,ip ")
RPTTITLE = "Active " & ddlOpt.SelectedItem.Text & " Users"
ElseIf ddlactive.SelectedItem.Text = "No" Then
tmp = "N"
ds1 = con.FetchData("select * from computer_mast where type='" & ddlOpt.SelectedItem.Text & "' and active='" & tmp & "' order by deptname,ip ")
RPTTITLE = "Not Active " & ddlOpt.SelectedItem.Text & " Users"
End If

If ds1.Tables(0).Rows.Count > 0 Then
lblErr.Visible = False
rptname = "~/Reports/Report3.rpt"
con.con.Open()
rpt.Load(Server.MapPath(rptname))
rpt.SetDatabaseLogon("wml", "win")
rpt.SetDataSource(ds1.Tables(0))
rpt.SummaryInfo.ReportTitle = RPTTITLE

CrystalReportViewer1.ReportSource = rpt

rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, "ExportedReport")

Else
lblErr.Visible = True
End If
con.dttemp = ds1.Tables(0)
Catch ex As Exception
MsgBox(ex.Message)
End Try
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900