DoCmd.RunCommand acCmdCopy Issue (2 Viewers)

Juett

Registered User.
Local time
Today, 07:58
Joined
Jul 16, 2019
Messages
71
Hi Everyone,

I have seen many variations on this problem, but nothing that quite relates to my own, specific issue.

I am trying to copy text from a field on a form and paste it into another text field on the same form. Both fields are standard text fields, from the same table.

The VBA command: DoCmd.RunCommand acCmdCopy does not work under any circumstance in my database. It juts throws the error:

Error 2046 'The command or action 'Copy' isn't available now'

I have tried creating new forms from scratch, new tables, new database files entirely...you name it. But the acCmdCopy function just keeps putting out that same error.

I have no idea what is causing this. I've checked record locks, allow additions, enabled, visible etc. in the form properties and all are correct. I have re-created a simple form with no other VBA code and just added the two text fields and nothing else....still won't copy. The paste command works fine, and I have checked the behaviour entering field as well.

Does anyone have any idea what might be causing Access to not allow this command to run? It always used to work in the past.

Thanks very much,

Chris
 

Minty

AWF VIP
Local time
Today, 07:58
Joined
Jul 26, 2013
Messages
10,353
There are two ways to achieve this using the clipboard or simply using the controls names and their values. The second is very simple.

Me.YourDestinationControlName = Me.YourSourceControlName

You don't need to use .Value for text boxes as it is the default property.

To answer your question you have to set focus to the control and select the text which is a PITA compared to the above.
 

Juett

Registered User.
Local time
Today, 07:58
Joined
Jul 16, 2019
Messages
71
Thanks Minty,

The full, original code is:

Me.Text1.SetFocus
DoCmd.RunCommand acCmdCopy
Me.text2.SetFocus
DoCmd.RunCommand acCmdPaste

It always used to work, but now, it suddenly won't. I just find it odd that the copy command would suddenly stop like that across the board.
 

Isaac

Lifelong Learner
Local time
Today, 00:58
Joined
Mar 14, 2017
Messages
8,738
Go with Minty's suggestion, you should never be copying and pasting values in your forms/gui
 

Users who are viewing this thread

Top Bottom