Click here to Skip to main content
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 16:33pm
Edited 11-Oct-12 0: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 Gihan Liyanage 332
1 Sergey Alexandrovich Kryukov 305
2 OriginalGriff 283
3 ClimerChinna 222
4 Abhinav S 187
0 Sergey Alexandrovich Kryukov 8,243
1 OriginalGriff 7,109
2 CPallini 2,598
3 Richard MacCutchan 1,980
4 Abhinav S 1,778


Advertise | Privacy | Mobile
Web01 | 2.8.140826.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2014
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