Advertisement

06.11.2007 at 10:48AM PDT, ID: 22626538
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Need MS Access VBA to copy and paste a column of text into clipboard to later paste into Excel, etc.

Asked by stephenlecomptejr in Microsoft Access Database

Tags: , , , ,

I have a subform displaying a column of equipment code values and I want the ability for the user to click on the label header to start loading in those values to the clipboard as a column to paste into Excel, Word, etc.  I already gained some coding to put something in the clipboard as text - but not an entire column listing of data.  Here is the coding I have thus far...  Do I have to put in a carriage return to facilitate the equip code listing.  An example of equip codes (string - sEq) would be:

02340
14031
23463
53801
g41
x40

Private Sub Text61_Click()
On Error GoTo Err_Something

  Dim sSQL As String
  Dim rs As DAO.Recordset
  Dim sEq As String
 
  ClipBoard_SetData ("")
  sSQL = "SELECT * FROM [PROJ_EQ] WHERE [Room_Number] = '" & [Room_Number] & "' ORDER BY [Equip]"
  Set rs = CurrentDb.OpenRecordset(sSQL)
  Do Until rs.EOF
    sEq = Nz(rs.Fields("Equip"), "")
    If sEq <> "" Then ClipBoard_SetEquip (sEq)
    rs.MoveNext
  Loop
  Set rs = Nothing
  SysCmd acSysCmdSetStatus, "done."
 
Exit_Something:
  DoCmd.Hourglass (False)
  Exit Sub
Err_Something:
  Call Error_Action(Err, Err.description, "frmItemListbyRoom @ Text61_Click", Erl())
  Resume Exit_Something
End Sub

Option Compare Database
Option Explicit

Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) _
         As Long
      Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) _
         As Long
      Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _
         ByVal dwBytes As Long) As Long
      Declare Function CloseClipboard Lib "user32" () As Long
      Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) _
         As Long
      Declare Function EmptyClipboard Lib "user32" () As Long
      Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, _
         ByVal lpString2 As Any) As Long
      Declare Function SetClipboardData Lib "user32" (ByVal wFormat _
         As Long, ByVal hMem As Long) As Long

      Public Const GHND = &H42
      Public Const CF_TEXT = 1
      Public Const MAXSIZE = 4096

Function ClipBoard_SetEquip(MyString As String)
         Dim hGlobalMemory As Long, lpGlobalMemory As Long
         Dim hClipMemory As Long, X As Long

         ' Allocate movable global memory.
         '-------------------------------------------
         hGlobalMemory = GlobalAlloc(GHND, Len(MyString) + 1)

         ' Lock the block to get a far pointer
         ' to this memory.
         lpGlobalMemory = GlobalLock(hGlobalMemory)

         ' Copy the string to this global memory.
         lpGlobalMemory = lstrcpy(lpGlobalMemory, MyString)

         ' Unlock the memory.
         If GlobalUnlock(hGlobalMemory) <> 0 Then
            MsgBox "Could not unlock memory location. Copy aborted."
            GoTo OutOfHere2
         End If

         ' Open the Clipboard to copy data to.
         If OpenClipboard(0&) = 0 Then
            MsgBox "Could not open the Clipboard. Copy aborted."
            Exit Function
         End If

         ' Clear the Clipboard.
         'X = EmptyClipboard()

         ' Copy the data to the Clipboard.
         hClipMemory = SetClipboardData(CF_TEXT, hGlobalMemory)

OutOfHere2:

         If CloseClipboard() = 0 Then
            MsgBox "Could not close Clipboard."
         End If

         End Function
Start Free Trial
[+][-]06.11.2007 at 10:52AM PDT, ID: 19260032

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.11.2007 at 11:02AM PDT, ID: 19260120

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.11.2007 at 11:11AM PDT, ID: 19260214

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Access Database
Tags: access, vba, copy, clipboard, paste
Sign Up Now!
Solution Provided By: capricorn1
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.11.2007 at 11:50AM PDT, ID: 19260530

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.11.2007 at 04:31PM PDT, ID: 19262662

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42