?
Solved

Crystal Report v7  SelectionFormula

Posted on 2003-10-27
4
Medium Priority
?
1,015 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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

719 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