Click here to Skip to main content
11,411,312 members (65,339 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: CrystalReports
hello

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 17:33pm
Edited 11-Oct-12 1:37am
v3
Rate this: bad
good
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")
  Permalink  
Comments
KimAugust at 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 at 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 at 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
good
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 149
1 Sascha Lefévre 110
2 OriginalGriff 103
3 Dave Kreskowiak 80
4 Maciej Los 78
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 6,983
2 Maciej Los 3,430
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2015
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