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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompting for parameters when report is printing!

Status
Not open for further replies.

Antzz

Programmer
Joined
Jan 17, 2001
Messages
298
Location
US
Hello Everyone,
I have a VB6 project using CRP 8.0. The VB6 app invokes a stored procedure to retrieve data and display on a Crystal Report. EnableParameterPrompting is set to false. While clicking on the print button from the Crystal Report display window, it prompts for parameters yet again.

Any advice to turn this prompt window after clicking the print button will be appreciated.

Thanks a lot

Antz
 
Does the report have subreports? This sounds like a case where the parameter isn't needed until you get to a page that contains something like a subreport..

Lisa
 
Lisa,
No there are no sub reports. It is just a plain simple report. I am using Report Viewer from within VB6.

It is very frustrating for the user as well as for me not being able to research the problem.

All help is appreciated.

Antz
 
Is there any code in the CRViewer's PrintButtonClicked event?

-dave
 
Dave,
I have some code which invokes a stored procedure and passes parameters to it. This is invoked as soon as the user clicks on it

Any idea?
 
Are you calling the CRViewer's Refresh method in the PrintButtonClicked routine?

If not, I'd like to see some of your code to try to duplicate your problem.

-dave

 
Here u go ....

Private Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)
Dim l_StartCustomer As Integer
Dim l_EndCustomer As Integer

l_StartCustomer = 0
l_EndCustomer = 0

If Trim(frmParam.txtParm(0).Text) <> "" Then
l_StartCustomer = CInt(frmParam.txtParm(0).Text)
End If

If Trim(frmParam.txtParm(1).Text) <> "" Then
l_EndCustomer = CInt(frmParam.txtParm(1).Text)
End If

'Call SP to update print flag here
Set lrec_Result = New adodb.Recordset
Set l_parameter = New adodb.Parameter

lcmd_Db.CommandText = "lvidb_rdm..sp_UpdPrintFlg"
lcmd_Db.CommandType = adCmdStoredProc

Set l_parameter = lcmd_Db.CreateParameter("@mode", adChar, adParamInput, 1, "A")
lcmd_Db.Parameters.Append (l_parameter)
Set l_parameter = lcmd_Db.CreateParameter("@start_cust", adInteger, adParamInput, 0, IIf(l_StartCustomer = 0, Null, l_StartCustomer))
lcmd_Db.Parameters.Append (l_parameter)
Set l_parameter = lcmd_Db.CreateParameter("@end_cust", adInteger, adParamInput, 0, IIf(l_EndCustomer = 0, Null, l_EndCustomer))
lcmd_Db.Parameters.Append (l_parameter)
Set l_parameter = lcmd_Db.CreateParameter("@cust_id", adInteger, adParamInput, 0, Null)
lcmd_Db.Parameters.Append (l_parameter)
Set l_parameter = lcmd_Db.CreateParameter("@resv_id", adInteger, adParamInput, 0, Null)
lcmd_Db.Parameters.Append (l_parameter)
Set l_parameter = lcmd_Db.CreateParameter("@prn_flg", adChar, adParamInput, 1, Null)
lcmd_Db.Parameters.Append (l_parameter)

Set lrec_Result = lcmd_Db.Execute
Set l_parameter = Nothing
lrec_Result.Close
End Sub
 
Well, I don't see anything that would cause the Viewer to attempt to refresh the report. If you comment out that block of code, does it still prompt you?

-dave
 
Yes, it still prompts me inspite of comments.
 
I think that your parameter(s) aren't getting passed to the report. When the report gets sent to the printer, it prompts if there are any parameters that haven't been set. How are you passing the parameter values to the report? Here are some examples:
[tt]
'Pass a date
Report.ParameterFields.GetItemByName("DateParam").AddCurrentValue CDate("1/15/03")

'Pass a string
Report.ParameterFields.GetItemByName("StringParam").AddCurrentValue "MyString"

'Pass a date range
Report.ParameterFields.GetItemByName("DateRange").AddCurrentRange CDate("1/15/03"), CDate("1/31/03"), 3

'Pass a number
Report.ParameterFields.GetItemByName("NumberParam").AddCurrentValue 6500
[/tt]
You could also run a test to see whether the parameter values were set before sending the report to the Viewer:
[tt]
Dim cParam As CRAXDRT.ParameterFieldDefinition
For Each cParam In Report.ParameterFields
Debug.Print cParam.Name
Debug.Print cParam.IsCurrentValueSet
Next
[/tt]
-dave
 
At form_load of the viewer(this is a partial post) :

Set crxp_Defs = rep_Coupons.ParameterFields
For Each crxp_Def In crxp_Defs
With crxp_Def
Select Case .ParameterFieldName
Case "@start_cust"
If Trim(frmParam.txtParm(0).Text) <> "" Then
.SetCurrentValue CInt(frmParam.txtParm(0).Text)
Else
.EnableNullValue = True
End If

Case "@end_cust"
If Trim(frmParam.txtParm(1).Text) <> "" Then
.SetCurrentValue CInt(frmParam.txtParm(1).Text)
Else
.EnableNullValue = True
End If
End Select
End With
Next
 
I am still having this issue. Any help will be greatly appreciated.

Thanks a lot in advance.
Antz
 
After some testing, I couldn't duplicate your problem. I was able to incorporate all of the code you provided (with a few tweaks), but never experienced the same behavior you've described.

If you'd like me to take a look at your code, you can email it to me (click on my handle to view my profile... it's in there) along with your .rpt file. Otherwise, I can't think of anything else.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top