|
-
April 21st, 2001, 01:30 AM
#1
Crystal Reports
I have crystal reports 6.0 installed. The report is made in Crystal Reports. How do I connect to it from my VB application and also how do I pass parameter to it.
-
April 23rd, 2001, 02:22 AM
#2
Re: Crystal Reports
'here some examples. Special thanks to Surrendermonkey.
Private Sub Command1_Click()
Dim sql As String
'your path and name to the rpt file
Cr1.ReportFileName = "D:\Condivisa\report\Report02.rpt"
'use crystal source type
Cr1.ReportSource = 0
'if you whant to change the where
'clause in an existing formula in your report:
Cr1.DiscardSavedData = True
sql = "{persona.Cognome}='Imperiali'"
Cr1.ReplaceSelectionFormula sql
'make it print:
'Cr1.Action = 1
'or:
myvar = Cr1.PrintReport
MsgBox myvar
'reset to enaboe again
Cr1.Reset
End Sub
Private Sub Command2_Click()
Dim sql As String
With Cr1
.ReportFileName = "D:\Condivisa\report\Report03.rpt"
.ReportSource = 0
Cr1.DiscardSavedData = True
'add a title to your report if you have a title field inserted:
.ReportTitle = "My title"
.Action = 1
.Reset
End With
End Sub
Private Sub Command3_Click()
Dim sql As String
Cr1.ReportFileName = "D:\Condivisa\report\Report04.rpt"
Cr1.ReportSource = 0
'if you dio not have a selection formula, create a new one:
'only the where clause:
Cr1.DiscardSavedData = True
sql = "{persona.Cognome}='Imperiali'"
Cr1.SelectionFormula = sql
'make it print
Cr1.Action = 1
'or:
'myvar = Cr1.PrintReport
'MsgBox myvar
Cr1.Reset
End Sub
Private Sub Command4_Click()
'A simply report with one parameter field
'called SelectMe in a omit formula for a section.
'Matter is not to make the selection (I can workaround using
'formulas). Matter is to pass a parameter value to a rpt file
'through Ocx - or: to make parameter fields to be filled
'via code form VB.
Cr1.Reset
Cr1.ReportFileName = "D:\Condivisa\Cesarevb\Crystol\cryweb\Report1.rpt"
Cr1.ReportSource = 0
Cr1.DiscardSavedData = True
Cr1.ParameterFields(1) = "SelectMe;1;false" 'parameter field name={?SelectMe}
'Cr1.ParameterFields(0) = "SelectMe;1;false"
'executing this following line I get the error 20553 "Name of parameter field not valid"
Cr1.Action = 1 'make it print
'oppure:
'myvar = Cr1.PrintReport
'MsgBox myvar
End Sub
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|