Results 1 to 2 of 2

Thread: Data Report using ADO

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    24

    Data Report using ADO

    Hi Everyone,

    First let me say I'm new to VB and to the forum so I wasn't sure if I should attached my problem to a previous thread "[Resolved] data reports with unbound controls" as it was already resolved.

    I am using Windows 98, VB6, Access 2000

    I created a report (rptResults) with unbound textboxes and want to populate it with records from an ADO recordset.

    I used the example from the previous thread and here is my code:

    VB Code:
    1. Set RptResults.DataSource = adoResults.Recordset.Datasource
    2.      With rptResults
    3.           With .Sections ("Section1").Controls
    4.                For i = 1 To .Count
    5.                     If TypeOf .Item(i) Is RptTextBox Then
    6.                     .Item(i).DataMember = ""
    7.                     [COLOR=Red].Item(i).DataField = adoResults.Recordset.Fields(i).Name[/COLOR]
    8.                     End If
    9.                Next i
    10.           End With
    11.      End With
    12. rptResults.show
    13. End Sub

    I get the following error:

    ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application.

    The red line is the line generating the error.

    Can someone please help?

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Data Report using ADO

    Try this...
    VB Code:
    1. Set RptResults.DataSource = adoResults.Recordset.Datasource
    2.      With rptResults
    3.           With .Sections ("Section1").Controls
    4.                For i = 1 To .Count
    5.                     If TypeOf .Item(i) Is RptTextBox Then
    6.                     .Item(i).DataMember = ""
    7.                     .Item(i).DataField = adoResults.Recordset.Fields(i-1).Name
    8.                     End If
    9.                Next i
    10.           End With
    11.      End With
    12. rptResults.show
    13. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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