How to Select the entire field on click?

G

Guest

Dear friends,
I created a form in Microsoft Access 2002 and there is a specific field in a
record which contains a java script,now I need to copy all the text in this
specific field to clipboard for pasting somewhere else,but to do so I am
selecting the whole text manually, now can anyone tell me if there is a way
by which whole of the text in the field can get selected automatically just
upon clicking.
 
G

Guest

In the OnClick event of the textbox (memo field):

Private Sub MyField_Click()
With Me.myMemoField
..SelStart = 0
..SelLength = Len(Me.myMemoField)
End With
End Sub

That should do it.

Steve
 
M

molsonexpert

I do this by entering this code into the onclick event of the text box
control:

Private Sub txtTextBoxControl_Click()
With Screen.ActiveControl
If .ControlType = acTextBox Then
.SelStart = 0
.SelLength = 15
End If
End With
End Sub

set the .sellength to the maximum length of data that would exist in the
text box.
 
G

Guest

Well I tried MolsonExperts's code and it worked well but how can I do the
programming so that the entire text in the field should get selected and
copied to the clipboard upon a single click.

I hope you guys will help..
 
L

LowFlyer

I used the following on a quick test form, and it seems to work:

Private Sub Text3_Click()

Text3.SelStart = 0
Text3.SelLength = Len(Text3.Text)

If Text3.SelLength > 0 Then
RunCommand acCmdCopy
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top