Entering 1st Field on Form Without Highlighting

N

nytwodees

I am using Access 2000.

I have a form that has a history by year of different fees. Each row on the
form has the:

-Year- - Fee Type- -Amount-

When the form is opened the cursor goes to the top row -Year- field. The
cursor blinks in that field and the contents of that field (2009) for
example, is highlighted. This highlighting makes it difficuld to read. Is
there any way to turn off the highlighting?
 
A

Arvin Meyer [MVP]

It might be easier to start with the cursor at the end of the textbox. That
was there is no highlighting.

Tools >>> Options >>> Keyboard tab >>> Go to end of field
 
N

nytwodees

Hi S. Clark:

Thank you for your rapid reply!

I appreciate that tip, but I was looking for a way to do this without user
intervention. (by code for example)
 
N

nytwodees

Hi Arvin:

Thanks for your reply.

The cursor is at the right end of the text box, but the highlighting is
still on.
 
J

James A. Fortune

Hi S. Clark:

Thank you for your rapid reply!

I appreciate that tip, but I was looking for a way to do this without user
intervention. (by code for example)

Once the control has the focus, you can change its SelLength property
to 0. That should remove the highlighting. Perhaps the form's Load
event is an appropriate place for such code.

James A. Fortune
(e-mail address removed)
 
T

Tom Wickerath

Try adding a very small text box to the form, named txtHidden, with the
following properties:

On Format properties tab
Visible: Yes
Width: 0
Height: 0
Back Style: Transparent
Border Style: Transparent

On Other properties tab
Tab Stop: No

Then add the following VBA code to the form:

Private Sub Form_Current()
On Error GoTo ProcError

If Me.NewRecord = True Then
Me.TextboxName.SetFocus
Else
Me.txtHidden.SetFocus
End If

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Form_Current..."
Resume ExitProc
End Sub


where "TextboxName" is the name of the text box control that you want to set
focus to for a new record. By the way, if you have a field or control on a
form named "Year", consider renaming it. Year is considered a reserved word
in Access:

Problem names and reserved words in Access
http://allenbrowne.com/AppIssueBadWord.html


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 
N

nytwodees

Thanks all for your help!

I was able to resolve the problem by creating this code for the ON ENTER
event procedure for that control:

Me!FeesCYr.SelLength=0
 

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