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

  • Thread starter Thread starter nytwodees
  • Start date Start date
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?
 
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.
 
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!!!
 
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?
 
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.
 
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
 
Back
Top