Error 2046

Rats

Registered User.
Local time
Today, 22:16
Joined
Jan 11, 2005
Messages
151
The following code has been used to simply copy the contents of two fields[memo] and [footer] to two other fields [memosent] and [footersent]. The code works up to the point where it reaches the "accmdcopy" for the second field. At this point I get a Run-time error 2046-the command or action copy isn't available now. The code following works OK if I exclude that line. I cannot see anything wrong with it.
My searches of this error do not provide any answers as they generally refer to opening and closing forms or reports when the Database window is not in view.

Can anybody throw some light on this please?
:confused:
Private Sub Command59_Click()
DoCmd.GoToControl "memo"
DoCmd.RunCommand acCmdCopy
DoCmd.GoToControl "memosent"
DoCmd.RunCommand acCmdPaste
Me.Footer.SetFocus
DoCmd.RunCommand acCmdCopy
DoCmd.GoToControl "footersent"
DoCmd.RunCommand acCmdPaste
DoCmd.GoToControl "memosent"
End Sub
 
Not sure why you are getting the error but wouldn't something like this be more efficent?

me.memosent = me.memo
me.footersent= me.Footer
Me.memosent.SetFocus



Peter
 
Rats said:
The following code has been used to simply copy the contents of two fields[memo] and [footer] to two other fields [memosent] and [footersent]. The code works up to the point where it reaches the "accmdcopy" for the second field. At this point I get a Run-time error 2046-the command or action copy isn't available now. The code following works OK if I exclude that line. I cannot see anything wrong with it.
My searches of this error do not provide any answers as they generally refer to opening and closing forms or reports when the Database window is not in view.

Can anybody throw some light on this please?
:confused:
Private Sub Command59_Click()

Me.Footer.SetFocus


Have you tried:
DoCmd.GoToControl "Footer"
 
I agree with BAT17, no need to "copy" to the clipboard to insert information to a control. The code BAT17 shows should work just fine.
 
Thanks for your help.

I agree that the code supplied would replicate the data in the new control, however, I need to be able to amend the text in the new control and leave the original text as is.

I am using this to store Form letters which can be selected and then modified resulting in a new "Letter Sent" but keeping the original Form Letter.

I found that the copy procedure is the only one that doesn't result in the original data being amended as well.
 
once the data is copied over it is independent from the source whichever way you do it. How are you altering the data that can affect two fields at once?

Peter
 
Thanks for your help. The error 2046 was occurring when one of the fields that was being copied was blank. I have now changed the process a little so that that field only gets copied when it contains data. The whole process now works well.
 

Users who are viewing this thread

Back
Top Bottom