?
Solved

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

Posted on 2006-11-12
3
Medium Priority
?
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Accepted Solution

by:
ast2550 earned 220 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 101

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

764 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