Solved

Referencing a variable in Crystal reports that is set in a windows form using VB.net

Posted on 2006-11-12
3
211 Views
Last Modified: 2012-06-27
I have a form that fires a crystal report...this works all fine ... the problem is I have the actual firing of the report within a loop, the actual report only returns 1 invoice number but based on the number of times the loop has to execute, the same report could be fired several times. I want to record the number of the loop in the actual report. For example , the first time through the loop I want to see the #1 on the report, the second time through I want to see the number #2 on the report, etc...

How would I pass that number into the report and what would I have to set up on the actual report to handle the value being passed??

This is the code I have so far. The variable "lnBagCount" determines the length of  the loop.Basically each time through the loop I want to see value of "D" to appear in the report...

        Dim cr2 As New CrystalReport3
        Dim strFilter As String
        Dim D As Integer
        strFilter = "{tInv.IID}= " & InvoiceID & ""
        CrystalReportViewer1.SelectionFormula = strFilter
        CrystalReportViewer1.ReportSource = cr2
        cr2.RecordSelectionFormula = "{tInv.IID}= " & InvoiceID & ""

        For D = 1 To lnBagCount
            cr2.Refresh()
            cr2.PrintToPrinter(1, False, 0, 0)
        Next

Now in the actual Crystal Report itself, I have following formula code that  shows the InvoiceNumber

StringVar InvoiceNumber;

InvoiceNumber := Replace(CStr({tInv.iInvNum}),".00" ,"" );

"*" & InvoiceNumber & "-" & D  & "*"

' if you notice the line above I want "d" to be appended to the invoice number, this is supposed the number of times the report has been printed

Any insight or help would be much apreciated...
0
Comment
Question by:nomar2
3 Comments
 
LVL 7

Accepted Solution

by:
ast2550 earned 55 total points
ID: 17930213
You need a parameter field in the report

Then you pass the value into the report through the parameter

http://www.codeproject.com/vb/net/CrystalContrl.asp
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 17930814
You could also add a formula to the report and change it from the VB code.

Here are some VB.Net samples.  

http://support.businessobjects.com/communityCS/FilesAndUpdates/vbnet_win_samples.exe.asp

mlmcc
0
 

Author Comment

by:nomar2
ID: 17937676
Thanks Ast2550... I added a parameter to the report called Parameter1

 and then on the vb side of the code I added the following

     For D = 1 To lnBagCount
            ' added this line to my code block
            cr2.SetParameterValue("Parameter1", D) ' populates the parameter in the Crystal rpt
            cr2.PrintToPrinter(1, False, 0, 0)
        Next
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now