Selecting varying number of chars in a textbox

D

Dennis

In Access 2003, I need to be able to highlight (select) a substring of the
text in a textbox for an existing record. For example, if I have a date:

3/10/2009

I might need to highlight the "3/10" part while leaving the "/2009" part
unhighlighted. This would facilitate data-entry of a month/day while leaving
the year as-is. I know this is possible, but have forgotten how. Can someone
please point me in the right direction?

Thanks a million!
 
T

Tom van Stiphout

On Wed, 17 Mar 2010 13:05:04 -0700, Dennis

Check the help file on SelStart and SelLength.

-Tom.
Microsoft Access MVP
 
M

Marshall Barton

Dennis said:
In Access 2003, I need to be able to highlight (select) a substring of the
text in a textbox for an existing record. For example, if I have a date:

3/10/2009

I might need to highlight the "3/10" part while leaving the "/2009" part
unhighlighted. This would facilitate data-entry of a month/day while leaving
the year as-is. I know this is possible, but have forgotten how. Can someone
please point me in the right direction?


Use the Enter event:

If Len(Nz(Me.textbox, "")) > 5 Then
Me.textbox.SelStart = 0
Me.textbox.SelLength = Len(Me.textbox) - 5
End If
 

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