Solved

Read contents of Crystal Reports text box in Visual Basic

Posted on 2011-03-13
3
426 Views
Last Modified: 2012-05-11
Hi experts,

How can I read the contents of a Crystal Reports text box in my visual basic application. My application shows invoices in a Crystal Reports. The user can navigate throught the invoices using the arrows of the CrystalReportViewer.
One of the text boxes of the report shows the invoice number. I want to be able to automatically export invoices to PDF files named by the invoice number (i.e. 1.pdf, 2.pdf, etc.)
Exporting to PDF is not a problem, but I need to know how to read the contents of my Crystal Reports text box (TxtInvoiceNumber) in my VB app.
How can I do that?
0
Comment
Question by:NoraWil
  • 2
3 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 35122958
This works frm VB6 with CR XI.  Not sure the properties are available through the .Net API

CRReportObject.Sections(SectionNumber).ReoportObjects("ObjectName").Text

You will need your own export button onthe report unless you can intercept the click of the export button.

mlmcc
0
 

Author Comment

by:NoraWil
ID: 35123257
Sorry mlmcc, but I'm not getting further this way. Writing to a Crystal Reports  text box works with


CType(CR.ReportDefinition.ReportObjects("TxtBox"), CrystalDecisions.CrystalReports.Engine.TextObject).Text = "My text"

But the opposite doesn't work.

The Crystal Reports ReportDocument has a Rows property. Perhaps it's possible to read the contents of one of the columns that way, but I can't find any documentation on that property.

0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 35123715
A I stated my syntax works from VB6.  The .Net API is different and I don't have a copy of it or a .Net environment to try it in.

Try this

mlmcc
Private Function GetTextObject _ 
         (ByVal reportObjectName As String) As TextObject
         Dim text As TextObject
      
         If TypeOf _
            (Report.ReportDefinition.ReportObjects. _ 
            Item(reportObjectName)) Is TextObject Then
            text = _ 
               Report.ReportDefinition.ReportObjects. _ 
               Item(reportObjectName)
            GetTextObject = text
         Else : GetTextObject = Nothing
         End If
      End Function

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with preventing selection from a combobox 11 40
Create a datatable in vb.net dynamically 1 38
Error message when using PrintSocket.Send 7 25
Access Schema 6 45
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 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