Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing string read from INI file into formula field generates error 1

Status
Not open for further replies.

syerin

Technical User
Oct 19, 2001
6
0
0
GB
Hello,

I'm running CR 8.5 and using VB6.0 as front end application. I'm trying to pass a string from VB into a formula field in CR. The following is what i have so far.

Dim fldFormulaFields As CRAXDRT.FormulaFieldDefinitions
Dim fldFormulaField As CRAXDRT.FormulaFieldDefinition
Dim DeviceDescription as string

Report.Database.AddADOCommand DB2Connection, DB2Command
Set fldFormulaFields = Report.FormulaFields
Set fldFormulaField = fldFormulaFields.Item(1)
fldFormulaField.Text = DeviceDescription

My problem is everytime i run the program i get error saying the remaining text doesn't appear to be part of the formula. DeviceDescription is read from an INI file so it's gotta be a string. How do i pass this in into CR?

Please help anyone..

Thanks.
 
Are you passing the string in with quotes around it? CR would need those for the string to be recognized as a string by the formula editor. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Hi Kenhamady,

Thanks for your reply. I tried to put quotes around the string as written below but when report is viewed, the output is printed as DeviceDescription instead of whatever values read from the file and stored in the variable DeviceDescription.

fldFormulaField.Text = " 'DeviceDescription' "
Result: the variable DeviceDescription is printed in the report.

any more ideas?


 
Sorry, don't make the variable name into a literal in VB, make the contents of the variable arrive as a literal in CR. Something like this:

fldFormulaField.Text = "'" & DeviceDescription & "'" Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top