Solved

how to pass parameters from VB to a CR 8.5 report

Posted on 2001-08-14
4
192 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 150 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 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…

808 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