Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
2.00/5 (4 votes)
See more:
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 , it should be display in the crystal report title.

Help me..


[edit]SHOUTING removed - OriginalGriff[/edit]
Posted
Updated 14-Apr-20 18:42pm
v3
Comments
Sergey Alexandrovich Kryukov 24-Mar-12 1:00am    
Please stop shouting. I mean, ALL CAPS is considered shouting on the Web, and rude. Please use correct capitalization, if you want to be taken seriously.
--SA
Dipak V Nakum 24-Mar-12 1:06am    
Dear SAKryukov ,i knowing very well ,if you know the answer then post it else seat silently.
Dipak V Nakum 24-Mar-12 1:06am    
Dear SAKryukov ,i knowing very well ,if you know the answer then post it else seat silently.
Sergey Alexandrovich Kryukov 25-Mar-12 4:07am    
"Post silently" is extremely rude. You are not welcome here.
--SA
OriginalGriff 24-Mar-12 4:10am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.

VB
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
 
v2
Comments
lalit agrawal 27-Aug-19 22:39pm    
Is that ok for crystal report but what about for subreport
how can we set report title for subreport using code in vb. Net
Well, you can just add a new Formula Field and pass value to that formula field from your vb.net.

That's it.

Hope this will solve your problem.
 
Share this answer
 
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 Sub


This is easiest way to set dynamic Title of any crystal report.
i hope this solve your problem
 
Share this answer
 
You can use crystal report's parameter field as the report title.

Dynamic values can be assigned to parameters.

Let me know in case you need more info.

Bhakti
 
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