Copy to clipboard

Yippiekaiaii

Registered User.
Local time
Today, 05:03
Joined
Mar 25, 2013
Messages
21
I have a form which contains a datasheet subform.

I want to be able to click a button that will copy the contents one of the fields of the currently selected record into the clipboard.

This is so that i can then paste it into another program.

I have tried the following code but it throws up an error telling me that "The command order action "copy" isnt available.

Private Sub Command82_Click()
[Items].Form![Description].SetFocus
DoCmd.RunCommand acCmdCopy
End Sub

Any ideas were i am going wrong or how to achieve my goal?
 
If you look at the bottom of your post you will find a number of threads on copying to clipboard
 
You have to select the data in the Control before copying, like:

Code:
TargetControl.SetFocus
Me.TargetControl.SelLength = Len(Me.TargetControl)
DoCmd.RunCommand acCmdCopy

Since the Subform is a Datasheet and cannot have Command Buttons, yours must be on the Main Form. If so, I believe you'll have to move Focus to the Subform Control first and then move Focus to the Control, itself, before copying.

Linq ;0)>
 
You have to select the data in the Control before copying, like:

Code:
TargetControl.SetFocus
Me.TargetControl.SelLength = Len(Me.TargetControl)
DoCmd.RunCommand acCmdCopy

Since the Subform is a Datasheet and cannot have Command Buttons, yours must be on the Main Form. If so, I believe you'll have to move Focus to the Subform Control first and then move Focus to the Control, itself, before copying.

Linq ;0)>

That you, this has worked!

However I have moved on slightly from this now. I need to now copy two fields to the clipboard so that when I paste them they paste as two separate columns in a table.

Is there way of copying two fields at once? Or adding a second copy to the first?

Basically my output paste would be occupy to adjacent cells on a spreadsheet or datasheet.

Any ideas?
 

Users who are viewing this thread

Back
Top Bottom