|
-
Dec 2nd, 2003, 02:11 PM
#1
Thread Starter
Frenzied Member
crystal parameter field
is there a way to stop Crystal from prompting me for a value. I already have the value that I need stored in crParameterDiscreteValue.Value
VB Code:
Dim crReport As New header()
Dim crParameterFieldDefinitons As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues()
Dim crParameterDiscreteValue As New ParameterDiscreteValue()
crParameterDiscreteValue.Value = CDate(tranPeriodEnd)
crParameterFieldDefinitons = crReport.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitons.Item("Dateparam")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Dec 16th, 2003, 04:57 PM
#2
Hyperactive Member
cant understnad why your code does not work, here is ours and it works perfectly:
Dim p2 As New ParameterFields
Dim p1 As New ParameterField
p1.ParameterFieldName = "RegUser"
Dim d1 As New ParameterDiscreteValue
d1.Value = RegisteredUser.CurUsr
p1.CurrentValues.Add(d1)
p2.Add(p1)
CrystalReportViewer1.ParameterFieldInfo = p2
and looks exactly the same
-
Dec 17th, 2003, 08:33 AM
#3
Thread Starter
Frenzied Member
how did you create a parameter field in crystal?
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Dec 17th, 2003, 11:43 AM
#4
Hyperactive Member
In the report designer, from field explorer, parameter field and then selected new.
I did have the same problem as you but that was just because I misspelt the name.
We use parameter fields of type string and date and they all seem to work, although frustratingly it took me ages to get them to work even though I carefully followed the examples.
The solution posted is for Crystal Reports Viewer
the following is the equivalent for when dealing with a report document and exporting the file in pdf format, but that is also the same for print to printer
both are working examples of code:
Dim d1 As New ParameterDiscreteValue
Dim p1 As New ParameterValues
If Not IsDBNull(dr1("CompanyName")) Then
d1.Value = dr1("CompanyName")
Else
d1.Value = " "
End If
p1.Add(d1)
Rpt1.DataDefinition.ParameterFields("CompanyName").ApplyCurrentValues(p1)
Dim d2 As New ParameterDiscreteValue
Dim p2 As New ParameterValues
If Not IsDBNull(dr1("Address1")) Then
d2.Value = dr1("Address1")
Else
d2.Value = " "
End If
p2.Add(d2)
Rpt1.DataDefinition.ParameterFields("Address1").ApplyCurrentValues(p2)
Dim d3 As New ParameterDiscreteValue
Dim p3 As New ParameterValues
If Not IsDBNull(dr1("Address2")) Then
d3.Value = dr1("Address2")
Else
d3.Value = " "
End If
p3.Add(d3)
Rpt1.DataDefinition.ParameterFields("Address2").ApplyCurrentValues(p3)
Dim d4 As New ParameterDiscreteValue
Dim p4 As New ParameterValues
If Not IsDBNull(dr1("Address3")) Then
d4.Value = dr1("Address3")
Else
d4.Value = " "
End If
p4.Add(d4)
Rpt1.DataDefinition.ParameterFields("Address3").ApplyCurrentValues(p4)
Dim d5 As New ParameterDiscreteValue
Dim p5 As New ParameterValues
If Not IsDBNull(dr1("Address4")) Then
d5.Value = dr1("Address4")
Else
d5.Value = " "
End If
p5.Add(d5)
Rpt1.DataDefinition.ParameterFields("Address4").ApplyCurrentValues(p5)
Dim d6 As New ParameterDiscreteValue
Dim p6 As New ParameterValues
If Not IsDBNull(dr1("StationeryChoice")) Then
d6.Value = dr1("StationeryChoice")
Else
d6.Value = " "
End If
p6.Add(d6)
Rpt1.DataDefinition.ParameterFields("StationeryChoice").ApplyCurrentValues(p6)
dr1.Close()
Cn1.Close()
Cmd1 = Nothing
Cn1 = Nothing
Dim RptPth As String = Application.StartupPath
Dim stopat As Integer = RptPth.LastIndexOf("\bin")
If stopat > 0 Then RptPth = Mid(RptPth, 1, stopat)
Dim exp1 As New ExportOptions
Dim dsk1 As New DiskFileDestinationOptions
Dim Fnam As String = RptPth & "\emails\" & "Remittance advice for " & CStr(ServiceProvider) & "-" & Trim(Name) & ".pdf"
exp1 = Rpt1.ExportOptions
exp1.ExportFormatType = ExportFormatType.PortableDocFormat
exp1.ExportDestinationType = ExportDestinationType.DiskFile
dsk1.DiskFileName = Fnam
exp1.DestinationOptions = dsk1
Rpt1.Export()
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
|