Crystal reports, RecordSelectionFormula

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 & "' "
Who is Participating?
cyberdevil67Connect With a Mentor Commented:
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)
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*'"

MylorAuthor Commented:
Nope, still not working.
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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.
MylorAuthor Commented:
Any examples?
has too, then something else is wrong, I use the code all the time...
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????????
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.