Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SelectionFormula in Crystal Reports

Status
Not open for further replies.

jaspers

MIS
Jan 20, 2003
6
US
I have created a report (Version 7) which will print orders with orderlines based on an orderID passed from Visual Basic 6.0.

I use the OCX and have the following code:

with CrystalReports1
.ReportFileName = App.Path & "\rptReport.rpt"
.SelectionFormula = "{tblOrder.OrderID}= & DblOrderID
.Action = 2
End With

What steps in the Report Designer do I have to take in order to set the parameter field in the reportdesigner to the orderID I pass from VB?

Thanx,

Jasper



 
You don't have to do anything in the report designer, as long as the string that you put after the selectionformula command is in valid Crystal Syntax. You probably DO need a quote on the end. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks for the quick reply.
What about the possibility of making parameter fields in the report designer and the sql statement I made with the report expert for selecting the fields on the report. I have to connect them somewhere?

Thanx again
 
If you add parameters to the report, you can use the Parameterfields command to pass values to them. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Jasper,
I was also stuck with this problem an hour ago. Google search result bring me to this thread. I read your line of code n tried it. After a couple of attempt i managed to run my report, i.e. getting selection criteria from the user at run time.
Your line of codes wasn't returning the selectionformula value as a string (or it can be number or anything). Anyway, your line of code helped me to solve my problem, in a way, i feel obliged to help you with yours.
Here is the code. I hope u can now use it in many ways.
Have a very good day,
Peace for All,
Fawad, Pakistan
uppal@wol.net.pk

Dim strGetvalue as string ' it can be number, date etc
Dim strformula as String

strGetvalue = trim(textbox.text)
strCriteria = "(tblOrder.OrderID)= '" & strGetvalue & "'"

With CrystalReports1
.ReportFileName = App.Path & "\rptReport.rpt"
.SelectionFormula = strformula
.Action = 2
End With

 
Hi
Please use the curly brakets to refer table field. Otherwise it will not work.
strCriteria = "{tblOrder.OrderID}= ' " & strGetvalue & " ' "
Fawad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top