Results 1 to 12 of 12

Thread: [RESOLVED] Eliminating Parameter Prompt in applcation?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Resolved [RESOLVED] Eliminating Parameter Prompt in applcation?

    I'm using CR 11 along with VB.Net. I have a report that takes 2 parameters that are passed from my VB App. My problem is that when I call the reporting procedure, I'm prompted by CR to enter my parameter values. Is there anyway I can prevent the prompt and pass the values to the report behind the scenes?

    Thanks,
    Blake

  2. #2
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Eliminating Parameter Prompt in applcation?

    can you post the code where you are passing them?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Eliminating Parameter Prompt in applcation?

    Here is the VB.Net procedure that creates, passes, and calls the CR.

    Code:
        Public Sub PrintGroupActivitySummary()
            Try
                dErr.clsModule = "modReports"
    
                Dim crDoc As New rptGroupActivitySummary
    
                With crConnectionInfo
                    .ServerName = "sTEST"
                    .DatabaseName = "DACK"
                    .UserID = "CRVBNETSQL"
                    .Password = "password"
                    .IntegratedSecurity = True
                End With
    
                'Create Crystal Parameter
                Dim parameterFields As CrystalDecisions.Shared.ParameterFields
                Dim parameterField As CrystalDecisions.Shared.ParameterField
    
                Dim spValue As CrystalDecisions.Shared.ParameterDiscreteValue
                Dim spValue1 As CrystalDecisions.Shared.ParameterDiscreteValue
    
                spValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                spValue1 = New CrystalDecisions.Shared.ParameterDiscreteValue
    
                parameterFields = New CrystalDecisions.Shared.ParameterFields
                parameterField = New CrystalDecisions.Shared.ParameterField
    
                parameterField.ParameterFieldName = "@userID"
                spValue.Value = mstrUserID
                parameterField.CurrentValues.Add(spValue)
                parameterFields.Add(parameterField)
    
                parameterField.ParameterFieldName = "@groupID"
                spValue1.Value = mIntGroupID
                parameterField.CurrentValues.Add(spValue1)
                parameterFields.Add(parameterField)
    
                'crDoc.RecordSelectionFormula = strFormula
                frmReports.crViewer.ParameterFieldInfo = parameterFields
                frmReports.crViewer.ReportSource = crDoc
                frmReports.crViewer.DisplayGroupTree = False
                frmReports.ShowDialog()
    
            Catch ex As Exception
                dErr.clsProcedure = "PrintGroupActivitySummary()"
                dErr.clsMsg = ex.Message
                dErr.OnlineErrorHandler(dErr.clsModule, dErr.clsProgram, dErr.clsProcedure, dErr.clsMsg)
            End Try
        End Sub
    Blake

  4. #4
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Eliminating Parameter Prompt in applcation?

    is it throwing an exception at all?

  5. #5
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Eliminating Parameter Prompt in applcation?

    I usually just use:

    crReportDocument.SetParameterValue("@paramName", paramValue)

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Eliminating Parameter Prompt in applcation?

    Since there is 2 parameters, what would the full syntax be?
    Blake

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Eliminating Parameter Prompt in applcation?

    Besoup,

    I actually just created 2 lines of your example and that seemed to work. However, the report is not showing the data like it should be.
    Blake

  8. #8
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Eliminating Parameter Prompt in applcation?

    try this
    vb Code:
    1. Public Sub PrintGroupActivitySummary()
    2.         Try
    3.             dErr.clsModule = "modReports"
    4.  
    5.             Dim crDoc As New rptGroupActivitySummary
    6.  
    7.             With crConnectionInfo
    8.                 .ServerName = "sTEST"
    9.                 .DatabaseName = "DACK"
    10.                 .UserID = "CRVBNETSQL"
    11.                 .Password = "password"
    12.                 .IntegratedSecurity = True
    13.             End With
    14.  
    15.             crDoc.SetParameterValue("@userID", mstrUserID)    
    16.             crDoc.SetParameterValue("@groupID", mIntGroupID)  
    17.  
    18.             frmReports.crViewer.ReportSource = crDoc
    19.             frmReports.crViewer.DisplayGroupTree = False
    20.             frmReports.ShowDialog()
    21.  
    22.         Catch ex As Exception
    23.             dErr.clsProcedure = "PrintGroupActivitySummary()"
    24.             dErr.clsMsg = ex.Message
    25.             dErr.OnlineErrorHandler(dErr.clsModule, dErr.clsProgram, dErr.clsProcedure, dErr.clsMsg)
    26.         End Try
    27.     End Sub

  9. #9
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Eliminating Parameter Prompt in applcation?

    Quote Originally Posted by blakemckenna
    However, the report is not showing the data like it should be.
    what do you mean?

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Eliminating Parameter Prompt in applcation?

    My report should be showing at the least...Literals and its not. Here is what 1 of 3 formulas look like that reference the Stored Procedures.

    Code:
    Formula 1
    Dim cnt1 as Number
    
    If {prcSelectGASR_NewIR;1.NewIR} > 0 Then
        cnt1 = {prcSelectGASR_NewIR;1.NewIR}
        formula = "New Incident Requests for " & {prcSelectGASR_NewIR;1.groupName} & ":    " & Replace (ToText (cnt1), ".00" ,"")
    Else
        cnt1 = 0
        formula = "New Incident Requests for " & {prcSelectGASR_NewIR;1.groupName} & ":    " & Replace (ToText (cnt1), ".00" ,"")
    End If
    prcSelectGASR_NewIR is a Stored Procedure. Below is the Select statement for this SP.

    Code:
    USE [DACK]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    
    ALTER PROCEDURE [dbo].[prcSelectGASR_NewIR]
    	(
    	@userID		varchar(25),
    	@groupID	int
    	)
    AS
    BEGIN
    
                 DECLARE @userIDStart	varchar(25)
                 DECLARE @userIDEnd	varchar(25)
                 DECLARE @groupIDStart	int
                 DECLARE @groupIDEnd	int
    
    	-- Check and initial for any nulls
    	IF @userID = null
    	    SET @userID = ''
    
    	IF @groupID = null
    	    SET @groupID = 0
    
    	-- set userID selection range
    	IF @userID > ''
    	     BEGIN
    	        SET @userIDStart = @userID
    	        SET @userIDEnd = @userID
    	     END
    	ELSE
    	     BEGIN
    	        SET @userIDStart = ''
    	        SET @userIDEnd = 'ZZZZZZZZZZZZZZZZZZZZZZZZZ'
    	     END
    
    	-- set userID selection range
    	IF @groupID > ''
    	     BEGIN
    	        SET @groupIDStart = @groupID
    	        SET @groupIDEnd = @groupID
    	     END
    	ELSE
    	     BEGIN
    	        SET @groupIDStart = 0
    	        SET @groupIDEnd = 99999999
    	     END
    
    	SELECT	B.groupName,		
    		Count(C.statusID) as 'NewIR'
    	  FROM	tblGroupMembers B,
    		tblRequest C
    	 WHERE	(B.roleID = 1)					AND
    		(B.empID Between @userIDStart And @userIDEnd)	AND
    		(B.groupID Between @groupIDStart And @groupIDEnd)	AND
    		(C.statusID = 13)					AND
    		(C.requestDate >= GetDate() - 1)			AND
    		(B.groupID = C.groupID)
      GROUP BY	B.groupName
    END
    Last edited by blakemckenna; May 23rd, 2008 at 10:09 AM.
    Blake

  11. #11
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Eliminating Parameter Prompt in applcation?

    I use this for VB6

    References:
    Crystal Reports Viewer Control
    Crystal Reports ActiveX Designer Run Time Library
    Code:
    ' Typical Variable Declarations
    dim crApp as New CRAXDRT.Application
    dim crRept as New CRAXDRT.Report
    dim crParamDefs as CRAXDRT.ParameterFieldDefinitions
    dim crParamDef as CRAXDRT.ParameterFieldDefiniton
    dim crDBTab as CRAXDRT.DatabaseTable
    
    ' Open Report File
    set crRept = crApp.OpenReport("WHATEVER.RPT")
    
    ' Logon to SQL server
    crRept.Database.LogonServer "p2ssql.dll", "server name", "database name", "userid", "userpassword"
    
    ' Set table locations (because my reports run against multiple servers)
    foreach crDBTab in crRep.Database.Tables
      crDBTab.SetLogonInfo "server name", "database name", "userid", "userpassword"
    next
    
    
    
    ' Disable Parameter Prompting for the end user
    crRep.EnableParameterPrompting = FALSE
    
    
    
    ' Gather the list of available parameters from the report
    set crParamDefs = crRep.ParameterFields
    
    ' Loop through all parameters in the report by name, filling in the appropriate parameter with the right value
    foreach crParamDef in crParamDefs
      select case crParamDef.ParameterFieldName
        case "SubTitle"
          crParamDef.SetCurrentValue "My Report Subtitle Goes Here"
        case "@BeginDate"
          crParamDef.SetCurrentValue datevalue(txtBeginDate)
        case "@EndDate"
          crParamDef.SetCurrentValue datevalue(txtEndDate)
        case "@IntegerParam"
          crParamDef.SetCurrentValue val(int(txtIntegerParam))
      end select
    next
    crViewer1.ReportSource = crRept
    crViewer1.viewReport

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Eliminating Parameter Prompt in applcation?

    I figured it out....

    Thanks for the help guys..
    Blake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width