Solved

How to prevent displaying prompt for parameters in Crystal reports?

Posted on 2002-04-04
7
470 Views
Last Modified: 2012-06-22
I create a file using Crystal Reports ActiveX control.
I pass parameters to report (see the code below) but user always is prompted by Crystal Reports to confirm parameters even the code passes them directly. What should I do to prevent displaying the parameter dialog box? I tried TRUE and FALSE, but prompt appears in both cases.
With crtReport
    .Reset
    .Connect = mstrRepCnn
    .ReportFileName = mstrDirName & "\" & mstrRepFRE
    .SelectionFormula = "{FRETemp.FRE} = '" & _
            lvwAccountAll.ListItems(i) & "' AND " & _
            "{FRETemp.BalanceDate} = #" & _
            lvwAccountAll.ListItems(i).SubItems(3) & "#"
    .ParameterFields(0) = "OldBalDate;" & _
            Format(lvwAccountAll.ListItems(i).SubItems(6), _
            "dd mmm, yyyy") & ";FALSE"
    .ParameterFields(1) = "NewBalDate;" & _
            Format(lvwAccountAll.ListItems(i).SubItems(3), _
            "dd mmm, yyyy") & ";FALSE"
    .Destination = crptToFile
    .PrintFileType = crptText
    .PrintFileName = "C:\" & Format$(gdatDate, "mmm-dd-yyyy") & "_" & _
            lvwAccountAll.ListItems(i) & ".txt"
    .DiscardSavedData = True
    .ProgressDialog = False

    .Action = 1                    ' This method generates the error number in case of error '
End With
0
Comment
Question by:timofeia
7 Comments
 

Expert Comment

by:nkunapaneni
ID: 6918358
Make sure that ParameterFields name "NewBalDate" matches with the Parameter in the report and make

   ParameterFields(1) = "NewBalDate;" & _
           Format(lvwAccountAll.ListItems(i).SubItems(3), _
           "dd mmm, yyyy") & ";True"
     
And check if there are any parameters left out in the reports that need the values.
0
 

Author Comment

by:timofeia
ID: 6918373
nkunapaneni, I tried it already. If I use True it displays the empty fields for parameters, if I use False it displays parameter dialog box with parameters already assigned. But in both cases parameter dialog box is displayed.
0
 

Expert Comment

by:nkunapaneni
ID: 6918440
Hi
If u use True = it will not display the dialogbox and will assign the value to the parameter

ANd false  - will not display the dialogbox and will not assign the vlaue to the parameter

For example
in my Report i have a Parameter "RptCriteria"  which is defined as string, and default values none. ANd i placed that parameter in the report header.

In my vb code i use
sRptCriteria  = "This is Parameter Value"
.ParameterFields(0) = "RptCriteria;" & sRptCriteria & ";True"

This will assign the Parameter the value properly with out displaying the dialog.

I hope this helps.


       
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:timofeia
ID: 6918454
nkunapaneni, I tested it a minute ago. It still displays parameter dialog box with empty fields for parameters. I do not know what is wrong. Parameter names are right, and I have 2 parameters only.
0
 
LVL 18

Accepted Solution

by:
mdougan earned 200 total points
ID: 6918634
Well, one option is to go back into Crystal and remove the parameters and instead use Formula fields.  You can reference a Formula Field in Crystal anywhere that you can reference a parameter field, I believe.  So, if you then set your crystal report formulas:

With crtReport
   .Reset
   .Connect = mstrRepCnn
   .ReportFileName = mstrDirName & "\" & mstrRepFRE
   .SelectionFormula = "{FRETemp.FRE} = '" & _
           lvwAccountAll.ListItems(i) & "' AND " & _
           "{FRETemp.BalanceDate} = #" & _
           lvwAccountAll.ListItems(i).SubItems(3) & "#"
   .Formulas(0) = "OldBalDate=" & _
           Format(lvwAccountAll.ListItems(i).SubItems(6), _
           "dd mmm, yyyy")
   .Formulas(1) = "NewBalDate=" & _
           Format(lvwAccountAll.ListItems(i).SubItems(3), _
           "dd mmm, yyyy")
   .Destination = crptToFile
   .PrintFileType = crptText
   .PrintFileName = "C:\" & Format$(gdatDate, "mmm-dd-yyyy") & "_" & _
           lvwAccountAll.ListItems(i) & ".txt"
   .DiscardSavedData = True
   .ProgressDialog = False

   .Action = 1                    ' This method generates the error number in case of error '
End With
 
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 6919830
Dates must be passed in a very specific format.  Date (yyyy,mm,dd)

Change

   .ParameterFields(0) = "OldBalDate;" & _
           Format(lvwAccountAll.ListItems(i).SubItems(6), _
           "dd mmm, yyyy") & ";FALSE"
   .ParameterFields(1) = "NewBalDate;" & _
           Format(lvwAccountAll.ListItems(i).SubItems(3), _
           "dd mmm, yyyy") & ";FALSE"

to


   .ParameterFields(0) = "OldBalDate;" & _
           Format(lvwAccountAll.ListItems(i).SubItems(6), _
           "yyyy,mm,dd") & ";TRUE"
   .ParameterFields(1) = "NewBalDate;" & _
           Format(lvwAccountAll.ListItems(i).SubItems(3), _
           "yyyy,mm,dd") & ";TRUE"

mlmcc
0
 

Author Comment

by:timofeia
ID: 6921102
mdougan solution works perfectly, thanx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now