Re: How can I copy multiple records from the Data Grid to the clipboar

From: Mark J. McGinty (mmcginty_at_spamfromyou.com)
Date: 02/19/05

  • Next message: Stephen Howe: "Re: ADO Shape and Subqueries"
    Date: Sat, 19 Feb 2005 05:19:53 -0800
    
    

    "Jir" <Jir@discussions.microsoft.com> wrote in message
    news:0790314A-9366-4360-AC94-874276CA4743@microsoft.com...
    > How can I copy multiple records from the Data Grid to the clipboard?

    You'll have to access the rows in the recordset yourself, and copy the
    values to the clipboard in a format that's understood by whatever app you'll
    be pasting into. If that app happens to be Excel, delimit (separate) field
    values with a tab character, and rows with a new line, e.g.,

    ' assumes rs is a clone of the recordset to which the grid is bound

        Dim i As Long, j As Long, buf As String

        If (Grid.SelBookmarks.Count > 0) Then
            For i = 0 To Grid.SelBookmarks.Count - 1
                rs.Bookmark = Grid.SelBookmarks(i)
                buf = buf & rs.Fields(0).Value
                For j = 1 To rs.Fields.Count - 1
                    buf = buf & vbTab & rs.Fields(j).Value
                Next
                buf = buf & vbCrLf
            Next
        End If

        buf = Left(buf, Len(buf) - 2)
        Clipboard.Clear
        Clipboard.SetText buf

    Good Luck,
    Mark


  • Next message: Stephen Howe: "Re: ADO Shape and Subqueries"

    Relevant Pages

    • Re: Access 2007 - Anyone having trouble with really large conversions?
      ... I have a fairly large app, ... program, which has added even more forms, queries and linked tables. ... get errors when opening a recordset for a linked table. ... So Access 2007 always seems to use Recordset2 objects for its forms and reports ...
      (comp.databases.ms-access)
    • VB6 Databound text boxes cease to coordinate with datagrid control
      ... Data from an Access database in my app fills a record set and this recordset ... is the data source to multiple text boxes, ... Create recordset from the database. ... Set the record set as datasource for a data grid. ...
      (microsoft.public.vb.general.discussion)
    • Re: Datareader, dataset, else?
      ... A DataReader is most closely analogous to a Read-Only/Forward-Only Recordset ... > I'm writing my first real asp.net app at my job, ... > seems like I have to choose between using a SQldatareader or a dataset. ...
      (microsoft.public.dotnet.framework.aspnet)
    • Pasting an image onto a form from an Access DB through automation
      ... data from the database query. ... image to the clipboard first. ... What I'd like to do is somehow get the image from the recordset field ... tblMemberPhoto.MemberPhoto FROM tblMemberPhoto WHERE tblMemberPhoto. ...
      (microsoft.public.word.vba.userforms)
    • Re: Application crashes with "On Error Resume Next"
      ... The code is intended to move data from one recordset to another - ... however the "ChangedCarveOuts" recordset is built using a stored proc ... Next is then to allow the app to skip any potential 3065 (Item cannot ... ran the app on a machine at the client site that uses MDAC ...
      (microsoft.public.vb.bugs)