• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

Formula fields value change from mfc application in crystal 9.0

i am using crystal 9.0 in my mfc application. i want to chagne value of one formula field (String) from my application. i am passing recordselectionformula which is running very well. but could not able to pass formula field value. can anybody help me out .

code is

m_pApplication.CreateInstance("CrystalRuntime.Application.9");
_bstr_t FileName("Test.rpt"));
m_pReport = m_pApplication->OpenReport(FileName);

_bstr_t RecordSelectionFormula(m_strRecSelString);
m_pReport->PutRecordSelectionFormula(RecordSelectionFormula);

this above code is working fine .. now for passing formua ..

formula name is String - @Caption

CString strCap = "This is report new caption";
pReport->FormulaFields->Item[1]->put_Text(_bstr_t(strCap.GetBuffer(strCap.GetLength())));

when i run this is get runtime error ..
'Remaining text doesn't appear to be part of formula'

amit
0
amlooks
Asked:
amlooks
1 Solution
 
frodomanCommented:
I believe the problem is that in order for this formula to produce the result you want, you have to pass the quotation marks into the formula as well.  I'm not sure of the syntax you need but for vb it would be changing this:

CString strCap = "This is report new caption";

To something like this:

CString strCap = ""This is report new caption"";


Another option is to create a parameter and pass the string value to the parameter instead of passing it to a formula.  If all you're using is static text here than a formula is really overkill.
0
 
mlmccCommented:
Actually since CR accepts both " " and ' ' for strings use

CString strCap = "'This is report new caption'";

If you want to use " then you need 3 of them.  The first one is used for the string in VB, the second and third produce 1 inside the string.

CString strCap = """This is report new caption""";

mlmcc
0
 
amlooksAuthor Commented:
i got my answer ... it was not problem of crystal but with VC++ ..
thanks frodoman .. i have used parameter field instead of formula field ..

please delete this question ..

0
 
frodomanCommented:
recommend split: frodoman & mlmcc

We both gave him the solution that solved the vc++ issue.
0
 
moduloCommented:
PAQed, with points refunded (125)

modulo
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Tackle projects and never again get stuck behind a technical roadblock.
Join Now