question

GilbertPeeters-4100 avatar image
0 Votes"
GilbertPeeters-4100 asked thedbguy answered

Problem with the following code : DoCmd.RunCommand acCmdPaste

I have the following code in MS-Acces VBA, when I click on the button called Paste_Bookmark :

Private Sub Paste_Bookmark_Click()
Me!hdrBookmarkLink.SetFocus
DoCmd.RunCommand acCmdPaste
End Sub

The URL that is currently on the clipboard will be pasted in the field Me!hdrBookmarkLink.
That's ok.

But when I want to edit another field I get the message :

"Another user edited this record and saved the changes before you attempted to save your changes.
Re-edit the record."

I can avoid this if I first hit the enter key, while the focus is still on the field Me!hdrBookmarkLink.
But I would like this to happen automatically, i.e. in the coding.

I tried with : DoCmd.GotoControl "OtherField" but this fails. It gives "Run-time error 2110 : cannot move the control ..."

I just need an Enter after the Past ...


TIA






95083-image.png




office-vba-devoffice-access-dev
image.png (9.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

thedbguy avatar image
0 Votes"
thedbguy answered

Hi. Just a guess, but try this:

 Private Sub Paste_Bookmark_Click()
 If Me.Dirty Then Me.Dirty=False
 Me!hdrBookmarkLink.SetFocus
 DoCmd.RunCommand acCmdPaste
 End Sub

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.