How do I select all contents in a form memo field on focus?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to specify how the cursor behaves on a field in a form. I
know that I can change the setting for the entire database in advanced
settings to either highlight all, go to end or beginnig of field, but I want
to be field specific.

For example, on the same form I want the cursor to go to the end of a memo
field called "description" so someone can add to what is there immediately on
focus, but in a comment field where I am listing the column history, I want
the previous info to be deleted or highlighted upon focus so that user can
just type in the new comment without having to manually select then type.
 
As you say, you can use Tools | Options | Keyboard to set the option for
every Control.

To set a single Control's contents to be completely selected, in the
GotFocus event, put your error handling and, for a Control named
"txtComment":

Me.txtComment.SelStart = 0
Me.txtComment.SelLength = Len(Me.txtComment)

To put the cursor at the end of the text in a single Control, in that
Control's GotFocus event, put your error handling and, for a Control named
"txtDescription":

Me.txtDescription.SelStart = Len(Me.txtDescription) + 1

Substitute your own Control names.

Larry Linson
Microsoft Access MVP
 
Thanks so much, that's exactly what i needed. Now i have another question
sort of releated. In a memo field that is set to "Yes" for the "Append Only"
property, is there a way to get that appended data to append to the beginning
instead of the end?

I think VBA can help me do a lot of the little things, would you happen to
know of any online sources where I could find a list of Access VBA code
commands so I would know what is available to work with. I think I could
figure out a lot of the syntax if I only new the commands available.

Thanks again.
 
Back
Top