|
-
Mar 12th, 2000, 07:55 PM
#1
Thread Starter
Lively Member
Hi, everybody!
I'm using 2 text boxes in a form as criteria to a SQL which feeds a Crystal reports. It's working nice, the problem is that I'd like the contents of the 2 text boxes (which are the report initial and final dates) to be displayed and printed in the report.
How can I do that?
Thanks in advance,
Roselene
-
Mar 12th, 2000, 08:55 PM
#2
Lively Member
Can you set the fields up as parameters in the crystal report and pass the values in before you execute the report?
-
Mar 12th, 2000, 09:16 PM
#3
Thread Starter
Lively Member
Bsmith,
Thanks for taking the time to help me. Could you please give me any further information? I'm afraid I can't understand your suggestion.
Thanks again,
Roselene
-
Mar 12th, 2000, 09:40 PM
#4
Lively Member
I guess my first question is are you running the Crytal Report from the Visual Basic program? If you are then inside Crystal Reports you can create a field that is a parameter. Before you set the Action=1 on the report you can set the parameters like this.
Code:
crystalreportobject.ParameterFields(0) = txtTextbox.Text
Your parameter fields should be populated with the values supplied from your code.
If you are not using VB to generate your report, then you may need to add the fields to your select from your database.
I hope this helps. I may need to see some code if you need more detail.
-
Mar 12th, 2000, 10:09 PM
#5
Thread Starter
Lively Member
bsmith,
Yes, I'm running Crystal reports from the VB program. There are 2 option buttons (Same name, different indexes) in a form in order to allow the user tho choose which report he/she wants to see/print.
I've put your suggestion in this option button click event:
CrRepNext.ParameterFields(0) = TxtDateIni.Text
CrRepNext.ParameterFields(1) = TxtDateFin.Text
but I have received the following error message:
4830 object doesn't support this property or method.
When I see the list of properties for my Crystal reports object (CrRepNext or CrRepNext1), it doesn't show a property called "Parameter Fields". I must be doing something wrong, but I can't put my finger on it.
Thanks again for all of your help,
Roselene 
This is the whole code for the event, in case you want to take a look:
Private Sub OptBtReports_Click(Index As Integer)
On Error GoTo ExecuteReportFail
Select Case Index
Case Is = 0
If DtReports1.Recordset.RecordCount = 0 Then
MsgBox "No data"
Else
CrRepNext.WindowState = crptMaximized
CrRepNext.ParameterFields(0) = TxtDateIni.Text
CrRepNext.ParameterFields(1) = TxtDateFin.Text
CrRepNext.PrintReport
Case Is = 1
If DtReports2.Recordset.RecordCount = 0 Then
MsgBox "No data"
Else
CrRepNext1.WindowState = crptMaximized
CrRepNext1.ParameterFields(0) = TxtDateIni.Text
CrRepNext1.ParameterFields(1) = TxtDateFin.Text
CrRepNext1.PrintReport
End if
End Select
Exit Sub
ExecuteReportFail:
MsgBox CStr(Err) + Error
' Resume OptBtReports_Click_Exit
End Sub
-
Mar 12th, 2000, 11:22 PM
#6
Lively Member
I am confused if the ParameterField property is not available. This is the property I use to set a parameter in the report. Did you try to use the help inside the Crystal Report designer? There might be some information there on passing parameters to the report. Sorry I couldn't be more help.
-
Mar 12th, 2000, 11:37 PM
#7
Lively Member
Create two textboxes where you want the dates to appear and then do something like this:
Private Sub Form_Load()
Dim Report As New CrystalReport1
Dim sStart as String
Dim sEnd as string
sStart = form.text1.text
sEnd = form.text2.text
Report.Text1.SetText sStart
Report.Text2.SetText sEnd
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
End Sub
That should work.
-
Mar 13th, 2000, 01:10 AM
#8
Thread Starter
Lively Member
Damonous:
I've tried you suggestion, but have received the error message:
User defined type not defined
regarding to the expression CrystalReport1 in the line:
Dim Report1 as New CrystalReport1
As I get an error message trying to use the bsmith's suggestion also, I guess that's something wrong with my VB. Is it possible that I have installed VB with some components missing? What should I do then?
Thanks again, folks 
Roselene
-
Mar 13th, 2000, 01:32 AM
#9
Lively Member
The "CrystalReport1" in the Dim Report1 as New CrystalReport1 statement should be replaced with the name you gave the report.
i.e. if you named the report Inventory, the Dim would be:
Dim Report1 as New Inventory
Try that before you decide to reinstall VB. :)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|