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".
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".
This error usually comes when the record is being saved twice. Your post doesn't provide much in the way of details, however!
I have used this code to duplicate a record in a form.
When I close the form, I get following message (In Excel I use Application.CutCopyMode = False to turn this mesage off):Code:Private Sub cmdDuplicate_Click() With DoCmd .RunCommand acCmdSelectRecord .RunCommand acCmdCopy .RunCommand acCmdPasteAppend .RefreshRecord .GoToRecord , , acLast End With End Sub
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..."
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
Thanks both of you for the tip,
I used the Function ClearClipborad() and it worked perfect.
Appreciate your help.
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