Run-time Error '2046' when using DoCmd.RunCommand acCmdCopy whilst browsing

C

cbazchin

I have a simple form in access.

There is one field on the form , DocID, which has the name of a document.
When the form is loaded, I want the docID to be copied onto the clipboard so
the user can paste this into another program without having to do a manual
keyboard or mouse routine. After doing the copy, it moves the focus to the
next field where a user could paste his results.

So, for the oncurrent event I wrote:

'copy the doc id value to the clipboard

DocID.SetFocus
DoCmd.RunCommand acCmdCopy

'Move focus to DocID1 field
DocID1.SetFocus


This works great if you acutally work with the record. No problems. The
problem arises when/if the user scrolls through the records, instead of
updating the record. Then I get the error:

Run-time Error '2046':
The command or action 'copy' isn't available now.

When I hit debug, it goes to the line: DoCmd.RunCommand acCmdCopy

Can anyone help me figure out why this doesn't work when you are
browsing/scrolling through the recordset?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top