繁体   English   中英

如何将值从文本框传递到Crystal报表

[英]How to pass values from textbox to crystal report

我有一个问题,即使我已经从VB表单的文本框中传递了值,Crystal报表仍提示我输入一个值。

这就是我创建参数的方式:

在Crystal报表中添加参数

如您所见,我将参数命名为NAME

这是我的代码,用于将TextBox的值传递给Crystal报表中的参数NAME

Private Sub indi_print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles indi_print.Click
    Dim locatorReport As New report_viewer

    Dim rptDoc As CrystalReports.Engine.ReportDocument
    rptDoc = New indi_locatorReport 'indi_locatorReport is the Crystal Report
    rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLegal
    rptDoc.PrintOptions.ApplyPageMargins(New CrystalDecisions.Shared.PageMargins(200, 200, 100, 1500))

    rptDoc.SetParameterValue("NAME", name_txtbox.Text)

    locatorReport.crptViewer.ReportSource = rptDoc
    locatorReport.ShowDialog()
End Sub

当我单击“ Print Button ,结果如下:

水晶报表输出

如您所见,Crystal Report提示我输入名称。 如何解决这个问题?

尝试

Dim rptDoc As New indi_locatorReport
rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLegal
rptDoc.PrintOptions.ApplyPageMargins(New CrystalDecisions.Shared.PageMargins(200, 200, 100, 1500))

rptDoc.SetParameterValue("NAME", name_txtbox.Text)

locatorReport.crptViewer.ReportSource = rptDoc
locatorReport.ShowDialog()

我已经解决了问题。 问题在于,每当窗体report_viewer加载时,它都会刷新水晶报表。 它具有Me.crptViewer.RefreshReport()代码。 我没有注意到这一点,因为Crystal Report查看器创建了此代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM