Emulate Ctrl+A on form

  • Thread starter Thread starter Martin
  • Start date Start date
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
 
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 -----
 
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
 
Back
Top