Results 1 to 9 of 9
  1. #1
    boomerang is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2011
    Posts
    16

    Double click a textbox to copy its value including format to clipboard

    I have a textbox on a form.

    Enabled: No
    Locked: Yes
    Format: "DC"0000

    I understand that to interact with it ‘Enabled’ will need to be set to yes?

    Basically I’d like to double click it and have its value copied to the clipboard. I’ve achieved this with the following code (but only when Enabled: Yes. Otherwise nothing happens).

    Code:
    Private Sub txtCaseNumber_DblClick(Cancel As Integer)  
       Dim objData As DataObject
       Dim strClipBoard As String
       Set objData = New DataObject
       objData.SetText ""
       objData.PutInClipboard
       strClipBoard = Me.txtCaseNumber.Value
       objData.SetText strClipBoard
       objData.PutInClipboard
       objData.GetFromClipboard
       strClipBoard = ""
       strClipBoard = objData.GetText
    End Sub
    
    The thing is, this doesn’t copy the formatting of the value, so I only get (for example) 444 and sometimes 0444 (bit sporadic if the preceding but important leading 0 comes too)
    I’ve tried to reproduce the formatting with the following addition to the code (additions indicated by !) but I get an error. Additionally, this won’t work when my values get so big that they get into the thousands. It would be nice if the code would just copy what is shown to the user on the form.

    Code:
    Private Sub txtCaseNumber_DblClick(Cancel As Integer)
     
       Dim objData As DataObject
       Dim strClipBoard As String
    !    Dim NewString As String
       Set objData = New DataObject
       objData.SetText ""
       objData.PutInClipboard
       strClipBoard = Me.txtCaseNumber.Value
       objData.SetText strClipBoard
       objData.PutInClipboard
    !    NewString = strClipBoard & “DC0”
       objData.GetFromClipboard
       strClipBoard = ""
       strClipBoard = objData.GetText
    End Sub
    
    Any help appreciated!

  2. #2
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    What exactly you want to format the data with creating an object?
    Do you just want to copy the data on certian form and show it on another form???

    If Yes, then you can just refer the field data on another form by referencing the field/control on user's form.

  3. #3
    boomerang is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2011
    Posts
    16
    Quote Originally Posted by khalid View Post
    What exactly you want to format the data with creating an object?
    Do you just want to copy the data on certian form and show it on another form???
    Hi

    No unfortunately I want to be able to paste the full, formatted value into an Outlook subject header.


  4. #4
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    I use the following script to send data to Outlook for mailing:

    Sub SendMail()
    On Error GoTo Err
    Dim objOutlook As New Outlook.Application
    Dim objEmail As Outlook.MailItem

    Set objEmail = objOutlook.CreateItem(olMailItem)
    objEmail.Recipients.Add Me!Text20
    objEmail.CC = "someAddress"
    objEmail.Subject = "Location Activation Request Approved (" & Me.Location & ")"objEmail.Body = "Mr./Madam," & vbCrLf _
    & Me.ReqName & vbCrLf _
    & "Good Day," & vbCrLf & vbCrLf _
    & "Your request to activate the following location has been approved: " & vbCrLf _
    & "================================================= =============" & vbCrLf _
    & "Location : " & Me.Location & vbCrLf _
    & "Status : " & Me.Status & vbCrLf _
    & "================================================= =============" & vbCrLf & vbCrLf _
    & "This is an automatic mail message generated by WO-Application." & vbCrLf

    objEmail.Display
    Exit_Err:
    Exit Sub
    Err:
    MsgBox Err.Description
    Resume Exit_Err
    End Sub
    Hope this gives some idea!

  5. #5
    boomerang is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2011
    Posts
    16
    Quote Originally Posted by khalid View Post
    I use the following script to send data to Outlook for mailing:



    Hope this gives some idea!
    Hi,

    Thanks for your time, but you're doing something completely different from what I am trying to do and it doesn't address my formatting issue.

    But I really, really appreciate your help.

  6. #6
    boomerang is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2011
    Posts
    16
    Anybody else? Please?

  7. #7
    boomerang is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2011
    Posts
    16
    Anybody ?

  8. #8
    boomerang is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2011
    Posts
    16
    oh dear !

  9. #9
    boomerang is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2011
    Posts
    16
    Lasd? Ey up?

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

Similar Threads

  1. On Double Click go to Subform
    By Theremin_Ohio in forum Access
    Replies: 2
    Last Post: 03-30-2011, 08:03 AM
  2. Use VBA to copy table contents to the clipboard?
    By Deutz in forum Programming
    Replies: 3
    Last Post: 10-21-2010, 10:59 PM
  3. Opening another form by double click
    By chrisjack001 in forum Access
    Replies: 1
    Last Post: 10-13-2010, 02:19 PM
  4. Rescrolling in ListBox on Double Click
    By jackkent in forum Access
    Replies: 6
    Last Post: 09-28-2010, 11:56 AM
  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