?
Solved

Call Report from VB??????  Pass Parameters from application....

Posted on 2001-06-25
8
Medium Priority
?
251 Views
Last Modified: 2007-11-27
I have a report I have been working on in Crystal 8 and have it finished.  The Record selection is as follows:

{Job.Job-ID} >= {?Job-ID} and
{Job.System-ID} = "IMG" and
{Job.Sub-Job-ID} = {?Sub-Job-ID}

Now I need to call the report from VB.  I have the parameter info at hand, but how do I call it?

Thanks in advance
0
Comment
Question by:Rog
[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
  • 2
  • 2
  • +1
8 Comments
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6225742
Give this a try

Private Sub Command1_Click()
  Dim crpParamDefs As CRAXDRT.ParameterFieldDefinitions
  Dim crpParamDef As CRAXDRT.ParameterFieldDefinition
  Dim crpSubreport As CRAXDRT.Report
  Set crpParamDefs = Report.ParameterFields
  For Each crpParamDef In crpParamDefs
    With crpParamDef
    Select Case .ParameterFieldName
      Case "MainParam"
        .SetCurrentValue "Main Report Parameter"
      Case "[CustomerID]"
        .SetCurrentValue "Alfki"
    End Select
    End With
  Next
  Report.EnableParameterPrompting = False
  CRViewer1.ReportSource = Report
  CRViewer1.ViewReport
End Sub
0
 

Expert Comment

by:Twingo
ID: 6227258
Are the paramaters, paramaterfields from a stored procedure or regular parameterfields ?

if regular => DRRYan3 has the anwser
0
 
LVL 8

Author Comment

by:Rog
ID: 6227768
Actually, the parameters I am asking about are neede when I run the program.  Crystal reports asks me to enter them so the report will run.  I am not too familiar with running crystal from VB.  I thought I could just put the crystal control on the VB form or use References then pass along the Record Selection statement changing where the ? variables above are, then print out the report.

Thanks,
0
Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6227779
Rog

That's what my code lets you do.  
0
 

Expert Comment

by:Twingo
ID: 6227849
If you put the crystal control in VB use this code :

Userid and Userpwd as strings

CrystalReport1.Connect = "DSN=DatabaseNAME;UID=" & UserID & ";PWD=" & UserPWD

CrystalReport1.ReportFileName = PrintCopyRPTName
CrystalReport1.SelectionFormula = ""
CrystalReport1.ParameterFields(ArrayIndex)[="ParameterName;
NewValue;SetCurrentValue"]

Arrayindex : means  0 for the first parameter,
1 for the second

example : To change the value of the first parameter field in a report (parameter1) to "red" use the following syntax (user will not be prompted to enter a value):
CrystalReport1.ParameterFields(0) = "parameter1;red;TRUE"

To change the value in a Date parameter field use the following syntax (user will not be prompted to enter a value):
CrystalReport1.ParameterFields(0) = "DatePar;Date(1998,12,7);TRUE"

To prompt the user to change the value of the third parameter field in a report (parameter3) use the following syntax (user will be prompted to use the default value set using the NewValue parameter below - "blue"):
CrystalReport1.ParameterFields(2) = "parameter3;blue;FALSE"
0
 
LVL 11

Accepted Solution

by:
arana earned 300 total points
ID: 6228415
try:

CrystalReport1.SelectionFormula ="{Job.Job-ID} >= " & vJOB & " and {Job.System-ID} = 'IMG' and {Job.Sub-Job-ID} = " & vSUBJOBID


JOB and SUBJOBID chould be your variables

be sure to clear the selection formula in your report, because if not above code will be ADDED to your current selection formula you have saved in your report.

that is if you have a selection formula saved in your report and it will be dynamic then erase it from your report and use it in your code.
0
 
LVL 8

Author Comment

by:Rog
ID: 6232591
This worked out great.  The other answers were good too, but this one was exactly what I was looking for.  Thanks.

Rog
0
 

Expert Comment

by:Twingo
ID: 6234362
Hint : If the number of record of the database get too large, using the selectionFormula may slow down the creation of the report.
This because the client has to do al the work.

Use a stored procedure as Database to your report and the server has to deal with all the selection work.

So for large tables wich you want to select out => use storer procedure ( faster )
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. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

752 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