Results 1 to 3 of 3

Thread: CrystalReport10 + DatabaseField

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    2

    Question 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:
    1. Function GetDatabaseField(ByRef Report As CRAXDRT.Report, ByVal FieldName As String) As String
    2. Dim RptTable As CRAXDRT.DatabaseTable
    3. Dim RptField As CRAXDRT.DatabaseFieldDefinition
    4. Dim FieldValue As String
    5. On Error GoTo Fehler
    6.  
    7. For Each RptTable In Report.Database.Tables
    8. For Each RptField In RptTable.Fields
    9. GetDatabaseField = RptField.DatabaseFieldName
    10. FieldValue = RptField.value
    11. Next RptField
    12. Next RptTable
    13.  
    14. Exit Function
    15. Resume
    16.  
    17. Fehler:
    18. Debug.Assert False
    19.  
    20. End Function

    Hope anyone can help me in this issue.

    thanks.

  2. #2

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    2

    Resolved 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:
    1. Option Explicit
    2.  
    3. Private WithEvents myReport As CRAXDRT.Report
    4.  
    5. Private Sub myReport_BeforeFormatPage(ByVal PageNumber As Long)
    6. Dim RptTable As CRAXDRT.DatabaseTable
    7. Dim RptField As CRAXDRT.DatabaseFieldDefinition
    8. On Error GoTo Fehler
    9.  
    10.   For Each RptTable In myReport.Database.Tables
    11.     For Each RptField In RptTable.Fields
    12.       Debug.Print RptField.DatabaseFieldName & " - " & RptField.Value
    13.     Next RptField
    14.   Next RptTable
    15.  
    16.   Exit Function
    17.   Resume
    18.  
    19. Fehler:
    20.   Debug.Assert False
    21.  
    22. End Sub

    Hope that I can help any other Developer with this solution.

    Regards
    Dani

  3. #3
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    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
  •  



Click Here to Expand Forum to Full Width