Solved

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

Posted on 2006-11-12
3
210 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

8 Experts available now in Live!

Get 1:1 Help Now