Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6198
  • Last Modified:

Crystal reports, RecordSelectionFormula

Hi,
I have an application in which I want to print a report based on a certain criteria. I created a Crystal with all the records but I just want to print only one record. Why by useing  RecordSelectionFormula , I am still getting all the records and not only one record?


        reportDocument1.RecordSelectionFormula = "{tblProb.Num} = '" & tmpNum & "' "
        CrystalReportViewer1.Show()
0
Mylor
Asked:
Mylor
  • 4
  • 2
  • 2
1 Solution
 
bman9111Commented:
Have to be like this::
 s = "'*" & tmpnum.text & "*'"
       
 reportDocument1.RecordSelectionFormula = "{tablename.fieldname}  like " & S

bottom line the formula must look like this:

reportDocument1.RecordSelectionFormula = "{tablename.fieldname}  like '*datatosearchby*'"

0
 
MylorAuthor Commented:
Nope, still not working.
0
 
cyberdevil67Commented:
I would actually use a parameter, and embed the syntax in the report that if the parameter is blank then returns everyting or returns the reocrd based on that criteria.

I think the Selction formula is based on the same sytnax as what you create in the report, so you would need to create that in there get it working in there and the bring it into the application with the way bman9111 suggested.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
MylorAuthor Commented:
Any examples?
0
 
cyberdevil67Commented:
Use the designer to add a parameter.

Then in the select expert create a new formula like this

{siInvoice.InvoiceNo} = {?StartingInvoice}

The in your Code

Report.SetParameterValue("StartingInvoice", tbInvoiceNo.Text)
0
 
bman9111Commented:
has too, then something else is wrong, I use the code all the time...
0
 
bman9111Commented:
try just doing this

reportDocument1.RecordSelectionFormula = "{tablename.fieldname}  like '*datatosearchby*'"

and just change the datatosearchby with what ever u wanting to search by


make sure u are typing the tablename correctly, and make sure u are typing the fieldname correctly, field name meaning the name on the left hand side, not the name that is presented when u right click on the field in ur crystal report design.

I just wrote another program today using the above code.

One more thing are u embedding this report or is it standalone????????
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now