|
-
Apr 11th, 2001, 09:23 AM
#1
Thread Starter
Addicted Member
I want to insert a string into a crystal report field. It is the user's actual name. What type of field do I need on the Crystal Report, and how do I tell VB to send this string to that field?
Normal is boring...
 smh 
-
Apr 11th, 2001, 10:17 AM
#2
Hyperactive Member
Insert a parameter in your report
then when you call the report in VB
go through the parameters collection for the report and set the new parameter to the required value.
Regards
Chris
-
Apr 11th, 2001, 10:21 AM
#3
Thread Starter
Addicted Member
Originally posted by chrisa_uk
go through the parameters collection for the report and set the new parameter to the required value.
Could you show me an example of how to do that?
Normal is boring...
 smh 
-
Apr 12th, 2001, 04:59 AM
#4
Hyperactive Member
There are a few ways to do this, but I use the following as I am not sure how to use the others.
Firstly your project needs to reference craxdrt.dll and and have component crviewer.dll. Now add a crystal report viewer to your form from the tool box.
you need the following declarations
Public reportToView As CRAXDRT.Report
Public subReportToView As CRAXDRT.Report
Public reportApp As New CRAXDRT.Application
Public params As CRAXDRT.ParameterFieldDefinitions
Public param As CRAXDRT.ParameterFieldDefinition
and then when you load the form:-
'insert your report name and path in the brackets
Set reportToView = reportApp.OpenReport(App.Path + "\summary.rpt", 1)
'if you have a sub report with parameters then you also need to open a sub report
Set subReportToView = reportToView.OpenSubreport("summary")
reportToView.EnableParameterPrompting = False
reportToView.ReadRecords
Set params = reportToView.ParameterFields
For Each param In params
With param
.ClearCurrentValueAndRange
'my parameter in CR is called startDate
If .Name = "{?startDate}" Then
'send your value here mine is a date
.AddCurrentValue CDate(Format(startDate, "dd-mmm-yyyy"))
Else
'I have another parameter in my report (endate) the parameter must be this
.AddCurrentValue CDate(Format(endDate, "dd-mmm-yyyy"))
End If
End With
Next
'open the sub report
reportToView.OpenSubreport ("summary")
'same agaim for parameters
Set params = subReportToView.ParameterFields
For Each param In params
With param
.ClearCurrentValueAndRange
If .Name = "{?startDate}" Then
.AddCurrentValue CDate(Format(startDate, "dd-mmm-yyyy"))
Else
.AddCurrentValue CDate(Format(endDate, "dd-mmm-yyyy"))
End If
End With
Next
'display the report
With rptExpenses
.ReportSource = reportToView
.ViewReport
.Zoom 1
End With
Hope this helps
Regards
Chris
-
Apr 12th, 2001, 08:52 AM
#5
Thread Starter
Addicted Member
THANK YOU!!! I have a good start, but I need to use 2 parameters, and I'm not sure how to do this.
I have to have the following:
?OrderDate = sOrderDate (which is working fine)
AND
?ATMID = sATMID (how do I add this in?)
Thank you again! You are a mindsaver!
Normal is boring...
 smh 
-
Apr 12th, 2001, 09:04 AM
#6
Thread Starter
Addicted Member
Here is the code that I have for the parameters section of the code to explain that a little better:
For Each param In params
With param
.ClearCurrentValueAndRange
If .Name = "{?OrderDate}" Then
.AddCurrentValue CDate(Format(sOrderDate, "dd-mmm-yyyy"))
End If
If .Name = "{?ATMID}" Then
.AddCurrentValue sOrderATMID
End If
If .Name = "{?UserName}" Then
.AddCurrentValue strFullName
End If
End With
Next
The report is pulling the correct orderdate from the database, and the username is correct, but it is pulling all the ATM's for the orderdate, not just the one stored in the sOrderATM variable.
Normal is boring...
 smh 
-
Apr 12th, 2001, 12:07 PM
#7
Thread Starter
Addicted Member
It is giving the correct information, but it is giving 2 pages of the same information. Do you have any idea why?
Normal is boring...
 smh 
-
Apr 17th, 2001, 02:44 AM
#8
Hyperactive Member
Does it give 2 pages of the same info if you open it in Crystal Reports or only in VB?
Regards
Chris
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
|