General discussion

Locked

Crystal Reports

By Uma_karanth ·
Hi there,
I working on Visual Basic 6.0, using Crystal Reports 6.0 as Report designer. My problem is that when I pass data to the Formula method of Crystal Report ActiveX which has both an apostrophe and Double Quotes the report does not print.
Ex.
CrystalReport1.formulas(1)="Data_Desc'" & sDesc & "'"
Note: sDesc is a string variable containing data S'Kool16"s
Since to the formula I can pass a data with either single Quotes or Double Quotes only if the data contains both apostrophe and Double quotes then the report does not print at all since there is this error.
Please, I need immediate help.....

Regards
Uma

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Crystal Reports

by RaviShankar In reply to Crystal Reports

Hi
if you want to send this value to your crystal report formula, you can do this

sDesc = " S''Kool16"" S "
CrystalReport1.formulas(1)="Data_Desc = '" & sDesc & "'"

Here I assined following characters
char(1) = S
char(2) = ' Single Quote
char(3) = ' Single Quote
char(4) = K
char(5) = o
char(6)=o
char(7) = l
char( = 1
char(9) = 6
char(10)=" Double Quote
char(11) = " Double Quote
char(12) = S

" (Double quotes) will be treated as escape char by VB, so two double quote will be treated as one double quotes . Also '(Single Quotes) will treated as esacpe char by Crystal Report.so while assinging a value to formula, sDesc will have S''Kool16"S
and two single quote will become one single quote by Crystal report execution. Write your own function to do this filteration.
I think you used 'On Error Resume Next' Statement, so that you not encounterd any run time error while excuting.

Hope this will help You
B. Ravi Shankar

Collapse -

Crystal Reports

by Uma_karanth In reply to Crystal Reports

Hi Ravi,
Thanks , but the problem still persists. The thing is I have written a function which will recognise the occurence of either single quotes or double quotes in a string. So when the string contains single quotes the functio will enclose the variable data within double quotes and if the variable contains double quotes in its data then the data will be enclosed within single quotes so it will be something like this
Public function ConverteQotes(sDesc as string)as string
if condition to check if single quotes exist in sDesc
ConverQuotes="""" & sDesc & """"
elseif double quotes then
ConverQuotes="'" & sDesc & "'"
end if
this is called in my main program as follows:
dim cConvert as new classname
rpt.Formulas(5) = "DL_Desc = " & cConvert.ConverteQotes(CStr(vDLHeader(0)))

so you can see that I am avoiding puting quotes here therefore when I use ur method it still does not function.

Regards Uma

Collapse -

Crystal Reports

by sl-campbell In reply to Crystal Reports

1): Using the Replace() function in VB change the single and double quotes to either:
A: some other char recognized by both VB and CR but that would never be in your data, or
B: Some text like "CVDBLQUOTE"

2). Pass this string to a second formula in CR.

3): In your first orig. formula creat a variable and assign it to the second formula.
Then, using the InStr and Mid functions in, find and replace these characters or strings with the actual characters.

Collapse -

Crystal Reports

by Uma_karanth In reply to Crystal Reports

Poster rated this answer

Collapse -

Crystal Reports

by Uma_karanth In reply to Crystal Reports

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums