"COPY AND PASTE" Macro Event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kappucino XL
    New Member
    • Aug 2009
    • 16

    "COPY AND PASTE" Macro Event

    Hi There..
    What is the Macro or Code Builder Event, For Copying And Pasting.
    i.e:

    I need to click on a field in a textbox, and it must be copied jus by clicking on it.
    Then I want to click on an empty textbox, and the field I copied must get pasted...

    How do I go About doing this?
    XL
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    I suppose you could use a form variable or a hidden textbox as a "clipboard" and copy the value of a text box to it when clicked. Then when the other text box is clicked, copy the value out of your clipboard.

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Can't really thik of a valid reason for doing this, but this code will work:

      Code:
      Private Sub FirstTextBox_DblClick(Cancel As Integer)
      If Not IsNull(Me.FirstTextBox) Then
        FirstTextBox.SelStart = 0
        FirstTextBox.SelLength = Len(Me.FirstTextBox)
        DoCmd.RunCommand acCmdCopy
      End If
      End Sub
      
      Private Sub SecondTextBox_DblClick(Cancel As Integer)
      If Not IsNull(Me.FirstTextBox) Then
        DoCmd.RunCommand acCmdPaste
      End If
      End Sub
      You really have to use the DoubleClick event for this. Using the OnClick event for a textbox to do something like this means that the user couldn't click into the textbox to enter data, very user un-friendly.

      Perhaps a little more explanation of your exact intent here would help us to better help you.

      Linq ;0)>

      Comment

      • OldBirdman
        Contributor
        • Mar 2007
        • 675

        #4
        I agree with Linq here, that this is user un-friendly. I would have a "Copy" command button next to the textbox to be copied. Although this would require an additional line of code "FirstTextBox.S etFocus" between lines 2 & 3, it would not do the automatic copy when such would be a hinderance.

        The Click Event occurs when a mouse button is pressed and released. Therefore, a user could select part of the text in FirstTextBox, but the entire text would be copied to the Clipboard. This is a behavior not standard to Windows, and because it is unexpected, might result in user-error.

        Can't really thik of a valid reason for doing this, but this code will work:
        I can and do use variations of this logic to lessen the number of keystrokes/mouse operations where copy/paste is used very frequently between related textboxes. However, I am VERY careful to avoid conflicts between this behavior and the Windows Clipboard.

        Comment

        Working...