Results 1 to 3 of 3
  1. #1
    Sck is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    82

    Copy the headerrow in a listbox to clipboard

    I have a listbox that displays values based on several queries selected by the user. I have code to pull the selected rows (all columns) to the clipboard but I can't figure out a way to pull the column headers. I have the column heads set to YES because it varies depending on the query results.



    is there a way to do this in Access 2007 VBA?

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Never seen this. Want to provide code for analysis?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Sck is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    82
    Simple code to get the data out of the listbox as a string:

    ColCount = Me.lstDetails.ColumnCount

    For Y = 0 To Me.lstDetails.ListCount
    If Me.lstDetails.Selected(Y) = True Then
    For X = 0 To ColCount
    str = str & Me.lstDetails.Column(X, Y) & vbTab
    Next
    str = str & vbCrLf
    End If
    Next

    The str is then sent to the clipboard. What I can't get is the column heads. The column heads change based on the queries that are selected. I could hard code the column heads but it would be a pain and I would think I could do it via a control property (like .ColumnHeaders in vb)

    FIGURED IT OUT:
    Checking to see if the row was selected was keeping the header from being copied. It is just a row in the list but it can't be selected. I added a step to copy row 0 every time and now it is working.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 06-21-2012, 11:43 AM
  2. Importing from clipboard?
    By mrrrgh in forum Access
    Replies: 5
    Last Post: 04-27-2012, 11:36 AM
  3. Replies: 8
    Last Post: 05-26-2011, 09:23 AM
  4. Use VBA to copy table contents to the clipboard?
    By Deutz in forum Programming
    Replies: 3
    Last Post: 10-21-2010, 10:59 PM
  5. Replies: 1
    Last Post: 03-13-2010, 08:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums