Emulate Ctrl+A on form

M

Martin

Hi

I want emulate pressing Ctrl+A on a text box within a form
so the user can select the entire contents of a text box.
I remember seeing it does using the Keypress event and
SelStart and SelLength methods.

Ctrl+A does not seem to work as 'Select All' as is does in
other windows applications

Can you help?

I am using Access2002
 
D

Dirk Goldgar

Martin said:
Hi

I want emulate pressing Ctrl+A on a text box within a form
so the user can select the entire contents of a text box.
I remember seeing it does using the Keypress event and
SelStart and SelLength methods.

Ctrl+A does not seem to work as 'Select All' as is does in
other windows applications

Well, it "selects all", all right -- but it selects *all records*, not
all text in the field.
Can you help?

How about this event procedure for the KeyDown event, for a text box
named "txtMyTextbox":

'----- start of example code -----
Private Sub txtMyTextbox_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyA And Shift = acCtrlMask Then
With Me!txtMyTextbox
.SelStart = 0
.SelLength = Len(.Text)
End With
KeyCode = 0
End If

End Sub
'----- end of example code -----
 
D

DebbieG

I think you're wanting the F2 key.

Debbie


Hi

I want emulate pressing Ctrl+A on a text box within a form
so the user can select the entire contents of a text box.
I remember seeing it does using the Keypress event and
SelStart and SelLength methods.

Ctrl+A does not seem to work as 'Select All' as is does in
other windows applications

Can you help?

I am using Access2002
 

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