Text Boxes and the Tab key

  • Thread starter Thread starter John C.
  • Start date Start date
J

John C.

I have a form that allows users to input comments into a
text box.

Sometimes it would be better written if they were able to
press the tab key to indent the information by 5
characters.

ANY way of trapping when the TAB key is pressed and
placing 5 spaces automatically?

Thankyou in advance.
 
Try pressing Ctrl-Tab. (Might work; might not; I don't have Access here to
check).

As for trapping the tab key, if you set the form's KeyPreview property to
True, then code the KeyDown, KeyPress and KeyUp events for the form, you can
see all keypresses before they actually get to the form. So maybe you could
trap the tab in KeyPress, see if the focus is currently on the control in
question, & if so, discard the tab (set KeyCode to 0), then do a SendKeys of
5 spaces? (YECHH!)

If you code the KeyPress event at the control level, be aware that the
control in question >will not< get the tab. The >next< control in "View Tab
Order" order will get the tab. This makes trapping tabs at the control
level, fairly difficult to do correctly.

HTH,
TC
 
Back
Top