Selecting all text in a record

J

Johnny Bright

Hi there!

In Access 2000 I would like my user to be able to click on a data point in a
record on a continuous form and have that block of text selected and copied
to the clipboard to be pasted elsewhere.
This:
Me.Vendor.SelLength = Len(Vendor)
Selects everything to the Right of where I clicked, but I would like it to
select the entire length of text.

This code block in a button....
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
....initially works but when I leave the text box I paste this into in
another form, all that is left behind in the field name (Vendor).

How can I get this to copy just the text or select just the text so it can
be copied.

All answers are greatly appreciated!
 
J

John Nurick

Hi Johnny,

Using the Value property of the textbox will give you its entire
contents. One simple way to put them on the clipboard is make sure your
VBA project has a reference to the MS Forms 2.0 object library, and then
use code like this, where XXX is the name of the textbox.

Dim s As String
Dim D As MSForms.DataObject

Set D = New MSForms.DataObject
D.SetText Me.XXX.Value
D.PutInClipboard
Set D = Nothing

If you want to minimise dependency on external libraries, there's code
at http://www.mvps.org/access/api/api0049.htm that uses the clipboard
API functions.
 
Top