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

Crystal and Visual Basic HELP!

Status
Not open for further replies.

B1naryPro

IS-IT--Management
Jan 20, 2002
114
0
0
US
I would like to pass a paramater from visual basic (Textbox) to the header of a crystal report. I have a text box with a date that the user selects in visual basic, i would like that value to show up on the reports header. any help greatly appreciated JPBinary
MCSE, MCSA
 
'The Application object is used to open an external RPT file as a Report object.
Public CrxApplication As New CRAXDRT.Application
Public CrxReport As CRAXDRT.Report

Set CrxReport = CrxApplication.OpenReport("Report.rpt")
CrxReport.ParameterFields.GetItemByName("Date").AddCurrentValue txtDate.Text
CRViewer1.ViewReport

You would have to create a parameter named Date in your report and set the Value Type to Date
 
Currently i have this code
Private Sub cmdView_Click()

Dim dteReturnValue As Date
Dim dteReturnValue2 As Date
Dim strControl As String
Dim strControl2 As String
Dim iResponse As Integer
dim rpttotalstats as

On Error GoTo ReportFailed

If IsDate(txtStartDate) And IsDate(txtEndDate) Then
dteReturnValue = txtStartDate
dteReturnValue2 = txtEndDate
strControl = Format$(dteReturnValue, "yyyymmdd")
strControl2 = Format$(dteReturnValue2, "yyyymmdd")

rpTotalStats.ReportFileName=gsReportPath"\CAOTotalStats.rpt"


rptTotalStats.SelectionFormula = "{CAO.DateReceived} in Date(" & Left(strControl, 4) & "," & Mid(strControl, 5, 2) & "," & Right(strControl, 2) & ") to Date(" & Left(strControl2, 4) & ", " & Mid(strControl2, 5, 2) & "," & Right(strControl2, 2) & ")"
rptTotalStats.WindowLeft = 0
rptTotalStats.WindowTop = 0
rptTotalStats.WindowState = 2
rptTotalStats.Action = 1 JPBinary
MCSE, MCSA
 
I think you need to create two parameters in your report, StartDate and EndDate. Then pass strControl to StartDate and strControl2 to EndDate.

rptTotalStats.ParameterFields.GetItemByName("StartDate").AddCurrentValue strControl

in your selection formula replace strControl with the parameters you created {?StartDate} and {?EndDate}

something like this I think :)

hope this helps

 
thank you for your help but this is how i did it and it works great....
rptCAOYeartoDate.Formulas(0) = "Yearly = '" + txtStartDate.Text & " " & "to" & " " & txtEndDate.Text + "'"
once again thanks JPBinary
MCSE, MCSA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top