Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically passing a Title from VB

Status
Not open for further replies.

SirPaladin

Programmer
Jul 9, 1999
32
0
0
US
I would like to be able to dynamically pass a Title that a user supplied in my VB 6 application to Crystal Reports. Anyone know?
 
I know this may seem strange, but I've answered my own question. If anyone else needs it, this answer assumes CrystalReport1 was renamed "PeopleDetail", that ReportSQL$ contains the SQL to select the records, and ReportTitle$ was supplied by the user as the title they chose:<br>
<br>
<br>
Dim Report As New PeopleDetail<br>
<br>
Option Explicit<br>
____________________________________________<br>
Private Sub Form_Load()<br>
Dim rs As New ADODB.Recordset<br>
<br>
If Len(ReportSQL$) = 0 Then<br>
MsgBox "Recordset not selected yet. Use the Query form first"<br>
Unload Me<br>
End If<br>
<br>
'Use this SQL statement to select the records to use<br>
rs.Open ReportSQL$, _<br>
"DSN=" & DSN$ & ";", adOpenKeyset<br>
Report.Database.SetDataSource rs<br>
<br>
If Len(ReportTitle$) = 0 Then<br>
Report.ReportTitle = "Detailed Personal Report"<br>
Else<br>
Report.ReportTitle = ReportTitle$<br>
ReportTitle$ = ""<br>
End If<br>
'CRViewer1.Name = "Test Name"<br>
CRViewer1.DisplayGroupTree = False<br>
CRViewer1.ReportSource = Report<br>
CRViewer1.ViewReport<br>
<br>
End Sub
 
You can create a formula field an position it in the report.<br>
You can then pass a value to the formula field from your Visual Basic Applicaiton.<br>
I am passing date ranges from a Delphi applicaiton that both control the date range and appear as part of the report title.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top