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!

Use Text Box with Record Selection Formula

Status
Not open for further replies.

mp001

Programmer
Oct 24, 2006
9
US
I'm trying to write a record selection formula using the version of Crystal Reports bundled with Visual Studio. Net 2003 that will allow a user to select the last name of a person using a text box. Here is my attempt that results in a runtime error.

Code:

string FormulaSelect;
"{Vendors.resLastName} = " + textBox3.Text;

myReport.DataDefinition.RecordSelectionFormula = FormulaSelect;


Runtime error:

Error in formula <Record_Selection>
'{Vendors.LastName}=smith'
A number, currency amount, boolean, date, time, date-time or string is expected here.


I am using the following MSDN sample I found on a web site:

Add a selection formula that contains the following:
{Customer.Last Year's Sales} > 11000.00
This formula returns records for customers whose sales from the previous year were greater than $11,000.00.

string selectFormula;
"{Customer.Last Year's Sales} > " + textBox1.Text;
Report.DataDefinition.RecordSelectionFormula = SelectFormula;


Any assistance would be appreciated.

Thanks,
Mark
 
There is indeed an error in the formula. {Vendors.resLastName} = {textBox3.Text} ought to work.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Madawc,

I get a "field name is not known" error with the following:

FormulaSelect = "{Vendors.resLastName} = " + "{textBox3.Text}";

FormulaSelect = "{Vendors.resLastName} = {textBox3.Text}";

Thanks,
Mark
 
Try removing the quotes. Or start again in a formula field and try placing the field from one of Crystal's display.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I have created a dynamic parameter that I would like to use in the record selection process using the LIKE option:

{Program.notes} LIKE "*{?pProgParam}"

The user wants to enter a partial name and get only appropriate matches.

The above selection does not work. I can only get it to work when I use a specific value such as:

{Program.notes} LIKE "*CRD"

This would then require a change every time the parameter changes. I don't want to have to do that. Any suggestions?
 
Madawc,

I get a syntax error if the quotes are removed. Thank you for your help.

Mark
 
EdChad--you should have started a new thread. Anyway, try the following instead:

{Program.notes} LIKE "*"+{?pProgParam}+"*"

I don't think this is technically considered a dynamic parameter. The dynamic option refers to accessing values in the database to populate a list of values, whereas you are allowing the user to select the values based on what they enter.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top