Results 1 to 7 of 7
  1. #1
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79

    Turn Off CutCopy Mode


    Hi,

    I have duplicated a record in a form. When I close the form I get a question if I want to save data in the clipborad. How can I prevent this question? In Excel I use "Application.CutCopyMode = False".

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    This error usually comes when the record is being saved twice. Your post doesn't provide much in the way of details, however!

  3. #3
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    I have used this code to duplicate a record in a form.

    Code:
    Private Sub cmdDuplicate_Click()
        With DoCmd
            .RunCommand acCmdSelectRecord
            .RunCommand acCmdCopy
            .RunCommand acCmdPasteAppend
            .RefreshRecord
            .GoToRecord , , acLast
        End With
    End Sub
    When I close the form, I get following message (In Excel I use Application.CutCopyMode = False to turn this mesage off):

    Click image for larger version. 

Name:	Untitled.png 
Views:	7 
Size:	14.7 KB 
ID:	26310

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Change it to an append query. Either you can save the query and run it - DoCmd.OpenQuery "qryname" - or you can run the SQL.

    I prefer not to keep too many query objects in the database so use SQL in VBA where possible. (1) create an append query and make sure that it works (2) go to SQL view and copy the SQL (3) go to VBA and enter DoCmd.RunSQL "...paste SQL string here..."

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    If you place this in a Standard Module:

    Code:
    Declare Function EmptyClipboard Lib "User32" () As Long
    Declare Function CloseClipboard Lib "User32" () As Long
    Declare Function OpenClipboard Lib "User32" (ByVal hWnd As Long) As Long
    
    
    Function ClearClipboard()
    
      If OpenClipboard(0&) <> 0 Then
    
       Call EmptyClipboard
      
       Call CloseClipboard
    
      End If
    
    End Function

    and use this in your Form:

    Code:
    Private Sub Form_Close()
      Call ClearClipboard
    End Sub

    it’ll dump anything in the Clipboard as the Form Closes.

    One caveat...name the Standard Module anything except ClearClipboard! Using the same name for the Module and the Function confuses the Access Gnomes no end!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Thanks both of you for the tip,

    I used the Function ClearClipborad() and it worked perfect.

    Appreciate your help.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 8
    Last Post: 06-26-2015, 06:00 PM
  2. Code runs in break/debug mode but not in normal mode
    By hansendl in forum Programming
    Replies: 2
    Last Post: 10-15-2014, 07:23 AM
  3. Replies: 4
    Last Post: 11-26-2013, 10:47 AM
  4. Replies: 2
    Last Post: 09-01-2011, 10:48 PM
  5. Replies: 4
    Last Post: 01-14-2011, 10:37 AM

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