Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello

i want to create crystal report with selection formula
i wrote
C#
string selectFormula =" {Customer.LastYearSales} > 11000 AND Mid({Customer.CustomerName}, 1, 1) = \"A\"";

it shows error
a string is require here
please help me find out what's wrong
Posted
Updated 11-Oct-12 0:37am
v3

If the formula is in Formula Editor of Crystal report then
I got this sort of problem myself a few months ago.

I did it like this:

{Customer.LastYearSales} > ToText("11000") AND MID({Customer.CustomerName},1,1) = ToText("A")
 
Share this answer
 
Comments
KimAugust 10-Oct-12 23:08pm    
hello thank you for your reply

the formula is not in Formula Editor

i use like this

string selectFormula =" {Customer.LastYearSales} > ToText(\"11000\") AND Mid({Customer.CustomerName}, 1, 1) = ToText(\"A\")";

crystalReportViewer1.SelectionFormula = selectFormula;
crystalReportViewer1.ReportSource = reportPath;

but the same error is pop up

and i test it in formula editor still the same error is popped up
please help me with this
Anaya Upadhyay 11-Oct-12 0:50am    
This might be the solution then -

Dim mySelectFormula As String = "{Customer.Last Year's Sales} > " & lastYearsSales.Text & " AND Mid({Customer.Customer Name}, 1) > """ & customerName.Text & """"

OR,

Dim mySelectFormula As String = "{Customer.Last Year's Sales} > 11000.00 " & "AND Mid({Customer.Customer Name}, 1, 1) = ""A"" "

For detail visit: this link.
KimAugust 11-Oct-12 6:44am    
hello thank u for your reply

here i test it with this
string selectFormula = "Mid({Customer.CustomerName}, 1, 1) = \"A\"";
no problem there it shows report customerName that starts with A

problem part is
if i wrote this
" {Customer.LastYearSales} > 11000" it says a number is required here
if i wrote change it to this
" {Customer.LastYearSales} > \"11000\"" it says a string is required here

help me my error thanks a lot
hello

finally i did like this and shows no error and i get the result

string selectFormula = " ToNumber( {Customer.LastYearSales} )> 11000.00"+
" and Mid({Customer.CustomerName}, 1, 1) = \"A\"";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900