'copy' isn't available now - just occurred, was OK

M

Mick Ruthven

I have an Access 2002 application that's been running for years. One feature
is a button on a form that copies the string contents of a control to the
clipboard. This morning it stopped working and gives this instead:

Run-time error '2046' - The command or action 'Copy' isn't available now.

Here is the code. It stopped on the "acCmdCopy" line. CtrlName is a variable
that contains the name of the control (I checked and it does contain it),
and the control contains the string to be copied (I checked that too). I
also tried "DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_COPY" and got the same
error.

DoCmd.GoToControl CtrlName
DoCmd.RunCommand acCmdCopy

Any ideas? This function has worked for years, including just a few days
ago, and I've not changed anything regarding Access other than creating a
new Access Project using SQL Server, but that should have nothing to do with
this standalone Access app. It's on a Win XP SP1 system.

Thanks,

Mick Ruthven
 
M

Mick Ruthven

I created the problem myself. I had changed the "Behavior entering field"
keyboard option in Access from "Select entire field" to "Go to start of
field". The DoCmd.RunCommand acCmdCopy depends on the text in the control
being selected, and the prior DoCmd.GoToControl CtrlName was going to the
control but not selecting the text. I set that option back to "Select
entire field" and it works fine. I do need to find a more robust method that
doesn't depend on that option being set a certain way. I found a page that
says it does just that. http://www.mvps.org/access/api/api0049.htm
 

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