Need VBA code that enters the F2 Key upon entering the Field

N

nytwodees

I am using Access 2000.

I understand that simply by pressing the F2 key while the cursor is in that
field, you can toggle Off and ON the highlighting for that field (textbox).

Can someone explain the necessary VBA code to perform this action without
the user's intervention?
 
D

Dirk Goldgar

nytwodees said:
I am using Access 2000.

I understand that simply by pressing the F2 key while the cursor is in
that
field, you can toggle Off and ON the highlighting for that field
(textbox).

Can someone explain the necessary VBA code to perform this action without
the user's intervention?


Set the control's SelLength property to 0. For example,

Me!txtMyTextBox.SelLength = 0

Note that you can only use this property when the control has the focus.
 
N

nytwodees

Hi Dirk:

I entered this code for the -On Enter- Event procedure and keep getting a
run-time error 2465.

Me!txtctlCurrentYear.SelLength=0

I don't know why I'm getting this error message! Help!!!
 
D

Douglas J. Steele

The text of the error message includes "You may have misspelled the field
name, or the field may have been renamed or deleted.". You sure the text box
is named txtctlCurrYear, and not, say, just txtCurrYear?
 
D

Dirk Goldgar

nytwodees said:
Hi Dirk:

I entered this code for the -On Enter- Event procedure and keep getting a
run-time error 2465.

Me!txtctlCurrentYear.SelLength=0

I don't know why I'm getting this error message! Help!!!


I agree with Doug -- check the name of the control.
 
N

nytwodees

Hi Dirk & Doug:

With your help the process is working the way I wanted it.

I changed the name of the control from:

CurrentYear to ctlCurrentYear to finally to FeesCYr

I took the suggestion that CurrentYear may be a protected word in Access.

Also I removed the "txt" before the control name. This I think was also
part of the problem.

So the final change were from:

Me!txtctlCurrentYear.SelLength=0 (Produced error message)
to
Me!FeesCYr.SelLength=0 (This works fine!)

Dan
 

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