Results 1 to 4 of 4

Thread: Sending Data to Datareport

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    150

    Sending Data to Datareport

    How do I send the data from a recordset to a datareport field?





    I have

    Set datareport1.datasource = RS



    now how do I say what to put in label1 in the datareport?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Sending Data to Datareport

    Only controls with a DataField property can be bound to the recordset.

    Before setting the DataSource property, set the DataField property to the name of a Field in the recordset.

  3. #3
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    Re: Sending Data to Datareport

    Hello bomayed,
    VB Code:
    1. Set rsReport = New ADODB.Recordset 'rs is the recordset object
    2.     rsReport.ActiveConnection = myConnectionString
    3.     strSelect = "SELECT bla,bla,bla " _
    4.               & "FROM tblBla " _
    5.               & "Where Bla = blablabla "
    6.    
    7.     rsReport.Source = strSelect
    8.     rsReport.Open
    9.    
    10.     Set drpt1.DataSource = rsReport
    11.  
    12.     drpt1.Sections("rptHeader").Controls("lblName").Caption = Trim(Adodc1.Recordset.Fields("pNAME"))
    13.     drpt1t.Sections("rptHeader").Controls("lblAddress").Caption = some rs(field) here
    14.     drpt1.Sections("rptHeader").Controls("lblCity").Caption = text1.text
    15.     drpt1.Sections("rptHeader").Controls("lblZipCode").Caption = "01234"
    16.  
    17.    
    18.     If rsReport.BOF = True And rsReport.EOF = True Then
    19.         MsgBox "Data Not Found!!!", vbMsgBoxRight + vbMsgBoxRtlReading
    20.         rsReport.Close
    21.         Set rsReport = Nothing
    22.         Exit Function
    23.     End If
    24.    
    25.     If rsReport.Fields("bla").Value = 0 Then
    26.         drpt1.Sections("Section5").Controls("Function4").Visible = False
    27.         drpt1.Sections("Section5").Controls("Label12").Visible = False
    28.         drpt1.Sections("Section5").Controls("Line9").Visible = False
    29.     End If
    30.  
    31.     drpt1.Sections("rptHeader").Controls("lblHeadLine").Caption = "Head Line"
    32.     drpt1.Sections("rptHeader").Controls("Label4").Caption = "something here..."
    33.                                                                
    34.     drpt1.Show (1)
    35.        
    36.     rsReport.Close
    37.     Set rsReport = Nothing

    Just An Example,
    Best Regards,
    ERAN
    Last edited by eranfox; Dec 14th, 2005 at 01:43 PM.
    Eran Fox
    ASSEMBLER,C,C++,VB6,SQL...

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Sending Data to Datareport

    Moved to Reporting section.

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