Results 1 to 1 of 1

Thread: Database.SetDataSource Unbound fields

  1. #1

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    54

    Database.SetDataSource Unbound fields

    I am very new to Crystal Reports and having problems to use it,

    My Setup
    1. Using VB 6
    2. Crystal Report 9
    3. Designing reports in VB using DSR

    Actually I have few questions....
    Q1. I have IFieldObject filed which, I set property "RightLineStyle - 1" and "BottomLineStyle - 2". Problem is that when this filed contains "" value, it dose not display LINES. Is I missed any property to SET to override this behaviour?
    What I already done to avoid it, I write code
    Code:
    IIf(Len(`tablename`.`filedname1`) = 0, ' - NIL -  ', tablename`.`fieldname1`)
    But I can not do this at every place, i have to print " " (space) on the report.
    Any Idea?

    Q2. Actually this problems arises when I am unable to produce record set through one Query (Due to some complex database setup/structure).

    For example I have Following Data, how i can print this on the report?

    Report is not attached/connected with any table
    FIVE unbound fileds on the report
    CModalChargesInfo is Class object
    VB Code:
    1. Dim infoChargesArray() As CModalChargesInfo
    2.     ReDim infoChargesArray(3)
    3.    
    4.     Set infoChargesArray(1) = New CModalChargesInfo
    5.     Set infoChargesArray(2) = New CModalChargesInfo
    6.     Set infoChargesArray(3) = New CModalChargesInfo
    7.    
    8.  
    9.     infoChargesArray(1).strVIA = "Data Row 1 - VIA"
    10.     infoChargesArray(1).dCharges = 200
    11.     infoChargesArray(1).strName = "Data Row 1 - Shipped"
    12.     infoChargesArray(1).strID = "Data Row 1 - ID"
    13.     infoChargesArray(1).dtDate = Now
    14.  
    15.     infoChargesArray(2).strVIA = "Data Row 1 - VIA"
    16.     infoChargesArray(2).dCharges = 200
    17.     infoChargesArray(2).strName = "Data Row 1 - Shipped"
    18.     infoChargesArray(2).strID = "Data Row 1 - ID"
    19.     infoChargesArray(2).dtDate = Now
    20.    
    21.     infoChargesArray(3).strVIA = "Data Row 1 - VIA"
    22.     infoChargesArray(3).dCharges = 200
    23.     infoChargesArray(3).strName = "Data Row 1 - Shipped"
    24.     infoChargesArray(3).strID = "Data Row 1 - ID"
    25.     infoChargesArray(3).dtDate = Now
    26.  
    27.    m_Report.Database.SetDataSource (infoChargesArray())
    28.    
    29.     With m_Report
    30.         .UnboundString1.SetUnboundFieldSource "infoChargesArray.strVIA"
    31.         .UnboundCurrency1.SetUnboundFieldSource "{infoChargesArray.dCharges}"
    32.         .UnboundString2.SetUnboundFieldSource "{infoChargesArray.strName}"
    33.         .UnboundString3.SetUnboundFieldSource "{infoChargesArray.strID}"
    34.         .UnboundDate1.SetUnboundFieldSource "{infoChargesArray.dtDate}"
    35.     End With

    I try to do this way, but it is not working .....

    Q3. I try accomplish same concept with some overload on system (creating Recordset through array),
    VB Code:
    1. Dim ary(5) As String
    2. Dim s As String
    3. Dim rs As New ADODB.Recordset
    4. Dim i As Integer
    5.  
    6. ary(0) = "VBForums"
    7. ary(1) = "Crystal Reports"
    8. ary(2) = "Urgent"
    9. ary(3) = "Very Urgent"
    10. ary(4) = "Problem"
    11.  
    12. rs.Fields.Append "Name", adVarChar, 20
    13.  
    14. rs.Open
    15.  
    16. For i = i To 5
    17. rs.AddNew
    18. rs!Name = ary(i)
    19. rs.Update
    20. Next

    Report.Database.SetDataSource rs 'THROWING EXCEPTION on this line(Subscript out of range) run-time error '9'

    Report.UnboundString1.SetUnboundFieldSource "Name"

    CRViewer91.ReportSource = Report
    CRViewer91.ViewReport

    But this code producing runtime error, I also try Report.Database.SetDataSource rs, 3, 1 (I saw some where on the forum)
    Report.Database.SetDataSource rs, 1, 3 (I saw some where on the forum)
    but both are not working.....

    HELP ME!!!

    I already spend alot of time to solve these problems.... but they are still on the same level.

    Thanks in advance to all
    Last edited by si_the_geek; Dec 17th, 2005 at 02:45 PM. Reason: added Code/VBCode tags

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