[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to pass parameters from VB to a CR 8.5 report

Posted on 2001-08-14
4
Medium Priority
?
223 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month19 days, 14 hours left to enroll

873 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