?
Solved

how to pass parameters from VB to a CR 8.5 report

Posted on 2001-08-14
4
Medium Priority
?
207 Views
Last Modified: 2008-02-01
I need to make a report of sales and what I do is to make teh report in CR then add the CR control to a form in VB and tell the control the ibucation from the file and the database. But my problem is that I need yo generate this report based on a range of day that I should enter from the program. how can I send this range to the report or how can I send some SQL statement from runtime?
0
Comment
Question by:matrix717
[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
4 Comments
 

Accepted Solution

by:
jimbo324 earned 600 total points
ID: 6385911
You can sort of send a SQL statement to the report using the ReplaceSelectionFormula.  Here is the syntax in VB:

crpt.ReplaceSelectionFormula ("{db.field} = '" & txt.text & "'")

crpt is the name of the crytal report control on your form.
db is the name of the database table.
field is the field name you are referring to.
txt.text is what you are trying to look for in the table.

Basically, this report will only show the data where field is equal to the text entered in txt...
0
 
LVL 7

Expert Comment

by:EYoung
ID: 6385944
My 2 cents:

Here is how I specify a SQL selection formula and how I pass two parameters to CR:

    If mSlsm_No_Parm <> "999" Then          ' Salesman not management
        Set Report = New dsrCall_Reports_Detail_Slsm
        Report.RecordSelectionFormula = "{Calls.Call_Date} >= Date(" & Format(mFrom_Date_Parm, "yyyy,mm,dd") & ")" & _
            " And {Calls.Call_Date} <= Date(" & Format(mThru_Date_Parm, "yyyy,mm,dd") & ")" & _
            " And {Calls.Slsm_No} = '" & mSlsm_No_Parm & "'"
    Else                                    ' Management not salesman
        Set Report = New dsrCall_Reports_Detail_Mgt
        Report.RecordSelectionFormula = "{Calls.Call_Date} >= Date(" & Format(mFrom_Date_Parm, "yyyy,mm,dd") & ")" & _
            " And {Calls.Call_Date} <= Date(" & Format(mThru_Date_Parm, "yyyy,mm,dd") & ")"
    End If

    Report.EnableParameterPrompting = False
    Report.ParameterFields(1).SetCurrentValue mFrom_Date_Parm
    Report.ParameterFields(2).SetCurrentValue mThru_Date_Parm


The above code should be placed in a form that contains a CRViewer1 control.

Best of luck.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6385998
Listening...
0
 

Author Comment

by:matrix717
ID: 6386157
Thanks a lot
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

762 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