|
-
Nov 23rd, 2005, 08:25 AM
#1
Thread Starter
New Member
CrystalReport10 + DatabaseField
Hi
I like to Read Data values from the Report directly, but there are still problems for me. The Value is still empty and i don't know why. In Crystal Help there is a comment on this property, but i didn't understand this: "Can be read only when top-level Report object is formatting active"
VB Code:
Function GetDatabaseField(ByRef Report As CRAXDRT.Report, ByVal FieldName As String) As String
Dim RptTable As CRAXDRT.DatabaseTable
Dim RptField As CRAXDRT.DatabaseFieldDefinition
Dim FieldValue As String
On Error GoTo Fehler
For Each RptTable In Report.Database.Tables
For Each RptField In RptTable.Fields
GetDatabaseField = RptField.DatabaseFieldName
FieldValue = RptField.value
Next RptField
Next RptTable
Exit Function
Resume
Fehler:
Debug.Assert False
End Function
Hope anyone can help me in this issue.
thanks.
-
Nov 25th, 2005, 03:22 AM
#2
Thread Starter
New Member
Re: CrystalReport10 + DatabaseField + Solution
Hello again
I found the solution for the described problem and let you know. You must declare you Report WithEvents. Then you can choose some Events from the Report. In this case I need the BeforeFormatPage Event. Only in this moment it is possible to get the data values directly form the Report.
Info: In case of this Solution I understand the Comment on the Crystal Reports Developer Help. They wrote: “The Value Property can be read only when top-level Report object is formatting active” That means the Event “myReport_BeforeFormatPage”
VB Code:
Option Explicit
Private WithEvents myReport As CRAXDRT.Report
Private Sub myReport_BeforeFormatPage(ByVal PageNumber As Long)
Dim RptTable As CRAXDRT.DatabaseTable
Dim RptField As CRAXDRT.DatabaseFieldDefinition
On Error GoTo Fehler
For Each RptTable In myReport.Database.Tables
For Each RptField In RptTable.Fields
Debug.Print RptField.DatabaseFieldName & " - " & RptField.Value
Next RptField
Next RptTable
Exit Function
Resume
Fehler:
Debug.Assert False
End Sub
Hope that I can help any other Developer with this solution.
Regards
Dani
-
Nov 25th, 2005, 04:53 PM
#3
Re: CrystalReport10 + DatabaseField
Thanks for posting your solution. I'm sure it will help others.
One comment on your code, you have a Resume statement immediately after Exit Function. This will never be executed and is redundant.
Thanks again.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|