Click here to Skip to main content
13,087,810 members (77,088 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i want to create crystal report with selection formula
i wrote
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 9-Oct-12 16:33pm
Updated 11-Oct-12 0:37am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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")
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 & """"


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
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


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\"";

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100