Datagrid contents to textbox

Posted on 2005-04-12
Last Modified: 2010-05-02
I have a datagrid that is retuirning some email addresses from a postgresql database...
I need to take the datagrid contents and copy it to a textbox on the form...only seperating each address with a comma...form mails these users...

My question is how do I get each row into a textbox? seperated by a comma?

datgrid control looks like this

I want to put that in a textbox like:,,

Question by:DonVF
    LVL 1

    Author Comment

    Or better yet....
    Why the heck won't this work?

    Dim rscount As Integer
    rscount = adoPrimaryRS.RecordCount

    For i = 0 To rscount
      Text1.Text = Text1.Text & adoPrimaryRS(i) & "," <---getting error on this line shown below
    Next i

    End Sub

    Everything is there and it counts correctly...and can return emails...

    The error is:
    Runtime error 3265
    Item can not be found in the collection corresponding to the requested name or ordinal.

    LVL 14

    Accepted Solution

    try this

    Private Sub FillTextBox(ColumnIndex As Integer)
        Dim i
        Text1.Text = ""
        For i = 0 To DataGrid1.ApproxCount - 1
            DataGrid1.row = i
            DataGrid1.col = column
            If Text1.Text = "" Then
                Text1.Text = DataGrid1.Text
                Text1.Text = Text1.Text & ", " & DataGrid1.Text
            End If
        Next i
    End Sub

    Private Sub Command1_Click()
    '    To get first column
         Call FillTextBox(0)
    '       To get Second column
    '       Call FillTextBox(1)
    End Sub

    LVL 1

    Author Comment

    well..filles the textbox then errors...saying invalid row number...8(
    LVL 1

    Author Comment

    blah an on error statement fixed it hehe

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now