Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Crystal Report v7  SelectionFormula

Posted on 2003-10-27
4
Medium Priority
?
1,026 Views
Last Modified: 2008-01-16
Hi all expert,

I have a VB6 program using Crystal Report Control trying to print a Crystal Report (v7).
The codes for printing worked fine.
     crysReport.Connect = PRptConn
     crysReport.ReportFileName = PReportPath & vRptName & ".rpt"
     crysReport.Action = crptToPrinter

But now I want to add codes to do something like we do directly in Crystak Report (v7):  Report  > Edit Selection Formula > Record...
I have a problem trying to pass a text value to  .SelectionFormula. I even tried to replace the single quotes with Chr(34) or Chr(39), but neither of then worked.
     crysReport.Connect = PRptConn
     crysReport.ReportFileName = PReportPath & vRptName & ".rpt"
     crysReport.SelectionFormula = "{TableName.FieldName}= '" & vValue &"'"
     crysReport.Action = crptToPrinter

I got an error message below:
                Run-time error '20515'
      Error in formula <Record_selection>.
      .
      .
      The remaining text does not appear to be part of the formula.

Please advise.

Thanks in advance and best regards.
0
Comment
Question by:mingichu
  • 2
4 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 800 total points
ID: 9628924
I think you may need a space before the =
Try this

crysReport.SelectionFormula = "{TableName.FieldName} = '" & vValue.Text &"'"

I usually use

crysReport.ReplaceSelectionFormula  "{TableName.FieldName} = '" & vValue.Text &"'"

mlmcc
0
 

Expert Comment

by:JMCrenshaw
ID: 9628948
I can remeber having a similar problem previously, much like some of the API calls strings must be Null Terminated. I found that by appending your string with a vbnull that worked for me and passing the Selection formula via a string rathern than directly into the object.

Example

crysFormulaString = "{TableName.FieldName}= '" & vValue & vbnull
crysReport.SelectionFormula = crysFormulaString

or  I have also used the Cstr() function

crysFormulaString = Cstr("{TableName.FieldName}= '" & vValue)
crysReport.SelectionFormula = crysFormulaString

Hope this helps !
0
 

Author Comment

by:mingichu
ID: 9629921
Thank you both very much for your quick response!!!!
I still got the same error when I tried the both solution using .SelectionFormula.

But it works using .ReplaceSelectionFormula.

Thanks a zillion for your help!!
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 9630808
Glad I could help.

mlmcc
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question