Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2001-06-25
8
Medium Priority
?
259 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 D
[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 D
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
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 D
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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…
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 …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

596 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