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!

VB - Crystal Reports - Preparsing Text Fields? 1

Status
Not open for further replies.

SalemGrafix

IS-IT--Management
Jun 12, 2003
46
0
0
US
It's probably going to be easiest to ask the question by giving a little background information, and what it is that I want to accomplish before asking the question:

We have a software package that connects to the SQL Server here at the school I work for. From that software, it also can launch Crystal Reports (designed by the company who makes the software, or by us, our IT department who designs custom reports). The program was wrote in VB, and the reports are designed with Crystal Reports 8.0 (or 8.5 depending on who is creating them).

The reports contain a text field in the report footer section, that when it contains the word "<SELECTION>" the program then parses the text field, and grabs information out of this field to allow user selection criteria. For example, if in the text field you specify that you want the user to select the semester, it then displays that in the end result for the end user of the software, prior to displaying the crystal reports.

I am designing another piece of software for use here at our school using VB, and would like to use this implementation as well. I have been able to read fields such as parameters, formula's, and running totals, but cannot seem to figure out a way to pre-read text fields into a variable from VB from a crystal report file.

I have been able to read text fields and the data they contain if I include the file (Project > Add Crystal Report 8.5 File) into the project, which is close, but I need to be able to pre-read files that aren't included in the project.

I am using Visual Basic 6.0 with SP6 and Crystal Reports 8.5 Developer Edition. I have a feeling that I'll need to use API calls, as the ActiveX controls don't seem to contain elements (text fields) that I'm looking for. I'm just not very fluent with API's, and have no idea how to set them up (without copy and paste from an example).

Any help would be great. Any other information needed to assist on this, please ask. Thanks. :)
 
There isn't a TextObjects collection like there is a FormulaFields or ParameterFields collection. To get to the Text Objects, you need to loop through each Section, then loop through the Section's ReportObjects collection looking for any report objects that are of the kind "crTextObject". Once you've got that far, you can read the Text property of the text object, and do with it what you will...

Here's a whitepaper that demonstrates this:

-dave
 
Wow, I didn't expect such a fast response, and especially didn't expect someone to understand and/or have the answer that quickly.

Just tested that out, and it worked!

After setting the report (using appplication.openreport(ReportName$)) and then connecting to it, I was able to parse thru the text fields using the following:

SelectionText$ = crxreport.sections(1).ReportObjects.Item(1).text

That is exactly what I was looking for, thank you very much for the response, and especially the correct answer!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top