Code Examples

Paste From Clipboard

acCmdPaste

This example copies information from the clipboard into the previous conrol. It assumes that you have used a button called cmdPaste.

'***************** Code Start *******************
' This code was originally written by Terry Wickenden.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.


Private Sub cmdPaste_Click()
    On Error Goto ErrPaste
    Screen.PreviousControl.SetFocus
    DoCmd.RunCommand acCmdPaste
    Exit Sub
ErrPaste:
    Select Case Err
      Case 2046
        'Previous control was not available for paste
        MsgBox "Paste is not available at this time.", vbCritical, ""Not Available"
        Exit Sub
      Case Else
        MsgBox Err.Number & ":-" & vbCrLf & Err.Description
        Exit Sub
    End Select
End Sub

'***************** Code End **********************

© 1998 - 2011 Terry Wickenden TKW Design Site developed, maintained and hosted by TKW Design. This site is best viewed at 1024 x 768. Optimised for Firefox.