Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using Parameters for Crystal Reports from VB.NET

Posted on 2005-04-12
12
Medium Priority
?
595 Views
Last Modified: 2008-01-09
I want to be able to print a report for several records from an Access database where record number will be = 1234, 4321, 6543, etc. not just one like in this case.

I have this code:

        tmpNum = txtNumber.Text
        rptreport = "C:\Problems\rptProblems.rpt"
        fp.reportDocument1.FileName = rptreport
        fp.reportDocument1.SetParameterValue("NumToPrint", tmpNum)

Thanks in advance,
0
Comment
Question by:Mylor
  • 5
  • 4
  • 3
12 Comments
 
LVL 9

Expert Comment

by:cyberdevil67
ID: 13766730
Hi Mylor,

If I read your post right then all you need to do is this..

Report.PrintToPrinter(1, False, 0, 0)

First Argument number of copies, second is Collation and the next 2 are staring and ending page.


Cheers!
0
 

Author Comment

by:Mylor
ID: 13766818
No, I need to print different records from the table.
0
 
LVL 9

Accepted Solution

by:
cyberdevil67 earned 1200 total points
ID: 13766831
Mylor,

i think i misread your question...

not sure if this works but this is how I do it..

reportDocument1.SetParameterValue("NumToPrint", "1234")
reportDocument.PrintToPrinter(1,False,0,0)
reportDocument1.SetParameterValue("NumToPrint", "4321")
reportDocument.PrintToPrinter(1,False,0,0)
reportDocument1.SetParameterValue("NumToPrint", "6543")
reportDocument.PrintToPrinter(1,False,0,0)
reportDcoument.Close()
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13766906
how is your NumToPrint parameter set up in Crystal?  Discrete values? Range?
0
 
LVL 9

Expert Comment

by:cyberdevil67
ID: 13766960
I don't use numToPrint..

I just copied yours..

i have that working with code here that runs every 5 secs and prints an invoice so the above must work.
0
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13767089
If you set up the NumToPrint parameter to take multiple values and reconfigure your report to group on the record number then you can send an array of NumToPrint's as the parameter value.  You would also have to adjust your record selection formula.
0
 

Author Comment

by:Mylor
ID: 13767909
Is as Discrete values and I want to add the values that I want to print in a listbox and then print them.
0
 
LVL 9

Expert Comment

by:cyberdevil67
ID: 13769315
My solution didn't work
0
 
LVL 34

Assisted Solution

by:Brian Crowe
Brian Crowe earned 800 total points
ID: 13769335
You can send over an array of values as your parameter.  You would need to include something like...

{myTable.[Record Number]} IN {?NumToPrint}[1 To Count{?NumToPrint}]

in your record selection criteria.
0
 
LVL 9

Expert Comment

by:cyberdevil67
ID: 13769346
BriCrowe

That would depend on the solution needed, but in the example I gave this was in a thread that checks a db and prints the invoice, what I was saying to Mylor is that you don't need to keep opening the report each and evrytime.

But hey I like that solution if they are all known at the time of printing the report:-)
0
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13772094
I agree cyber, I was just presenting the option.  The advantage of your solution is that it doesn't require any changes to the .rpt  The advantage of sending all of the records as a single parameter is that it only has to process the report once so it runs a little faster.  Yet another solution is to populate a temporary table with the records and configure your .rpt to join to that table.  This last solution may run into concurrency issues if not handled correctly though.
0
 

Author Comment

by:Mylor
ID: 13774757
Thank you guys!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

810 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