[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

how to pass parameters from VB to a CR 8.5 report

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
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…
Suggested Courses

656 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