Solved

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

Posted on 2006-11-12
3
215 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 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 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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