Solved

how to pass parameters from VB to a CR 8.5 report

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now