Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Unbound Field to Clipboard 1

Status
Not open for further replies.

number2

Technical User
Oct 25, 2001
284
US
I would like to create a button on a form which will copy the contents of an unbound field to the clipboard.

I have been unsuccessful in my attempts. Any ideas?
 
Surpisingly, it is not a straightforward process to copy text to the clipboard, however, it is quite doable. It requires a number of API calls to allocate some memory, lock it in place, then copy the string into the locked memory block. Then you open the clipboard, and copy the memory block by meomry handle into the clipboard and then clean up.

If you're (or anyone else) is serious about going down this road, I'll be glad to paste some code.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
You might also try first to setfocus to the control (the Enter Key Behavior in Tools | Options should have the "Select entire field" option selected, I think), and use the runcommand method of the docmd object, with the following command/argument:

[tt]me!txtSomeControl.SetFocus
docmd.runcommand accmdcopy[/tt]

Roy-Vidar
 
Thanks for the help!
RoyVidar, I tried your method and it selects the text the txt, but does not copy it. Any ideas?
 
So, if you open for instance Notepad after hitting the button, and then hit CTRL+V, you don't get the value from the control?

Roy-Vidar
 
Got it! Thanks Roy!
You made a difficult task easy! You get a Star!
 
One of these days, I'm going to have to become more familiar with all of the various DoCmd options. Nice work RoyVidar.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thank you! Both the star and the very kind words are appreciated!

CajunCenturion:
And one of these days I'll have to get started on APIs;-)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top