Highlighting Text in a Field

  • Thread starter Thread starter Freddy G
  • Start date Start date
F

Freddy G

I have a simple problem that is driving me crazy. All i
want to do is highlight the text in a field as a user tabs
through them in a Datasheet subform.

First let me start by saying that I'm aware that there is
a way to default it to do so under in Tools/Options -
Keyboard tab, but it has been set to "Go To Start of
Field" so that I can control when the text is highlighted
(our users had a knack for "accidently" hitting a
character and unknowingly overwriting information that was
highlighted)

Anyways, I have the following code which works fine when
using it for a Form, but when I use it for a Datasheet it
won't highlight the text:

< Private Function HighlightField(currField As TextBox)
< currField.SelStart = 0
< currField.SelLength = Len(currField)
< End Function

Each text box that I want to allow highlighting on uses
the following code in its GotFocus event:

< Private Sub txtLoanAmt_GotFocus()
< Call HighlightField(Me.txtLoanAmt)
< End Sub

Can anyone explain a fix, or another solution for
highlighting text for a Datasheet? Is there a way I could
change the Keyboard Options using code when this datasheet
is opened to "Select Entire Field" and change it back
to "Go To Start of Field" when the form closes?

Thanks in advance.
Freddy G
 
Hi Freddy,

My name is Dennis Schmidt. Thank you for using the Microsoft Access
Newsgroup.

Datasheet views are very limited in how they can be customized. However,
you can create a form that looks just like a datasheet but gives you the
full functionality of a form.

Create a form where the labels for your controls are in the form header.
Place all your controls side-by-side in the detail section and make the
detail section only as high as the controls (so there would be no space
between rows of records). Set your form to be in Continuous Form View and
you will have a form that looks like datasheet view. Any functionality
that you want to use for each individual control will now work.

I hope this helps! If you have additional questions on this topic, please
reply to this posting.

Need quick answers to questions like these? The Microsoft Knowledge Base
provides a wealth of information that you can use to troubleshoot a problem
or answer a question! It's located at
http://support.microsoft.com/support/c.asp?M=F>.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.

Regards,
Dennis Schmidt
Microsoft Support
 
Back
Top