SelStart

tazz25

New member
Local time
Today, 02:07
Joined
Jun 24, 2009
Messages
5
I'm new to Access 2007. I have a database with fields that have default text in them. When I tab to those fields, it selects all the text and puts the cursor at the beginning. I want it to automatically put the cursor at the end of the default text.

All I should have to do is count the length of text that's in the box and then move to that number, right?

So here's what I have done to try to do that...

I go to the properties of that box, click on the "On Enter" procedure and selected code. It takes me to the code screen, and I type:

Code:
Private Sub Extra_Info_Enter()
    Me!Extra_Info.SelStart = me!Extra_Info.SelLength
End Sub
And then I close the code screen. It should work, right?

Well it doesn't. It doesn't do anything differently. So, something isn't right.

So, next, just for the sake of debugging, I didn't get the length, I just set it to a number, like this:
Code:
Private Sub Extra_Info_Enter()
    Me!Extra_Info.SelStart = 3
End Sub
It should put the cursor at the 3rd character, simple enough...

It doesn't work either.

I don't know what else to try...

Please help...
 
Just use:

Me.TextBox.SelStart = Len(Me.TextBox)
 
Nope, that didn't work either. I mean the problem is that SelStart isn't working. I can't even say SelStart = 3. It ignores that line.

I think something else is wrong.
 
Use the GOT FOCUS event instead of Enter.
 
Yeah, I though of that too... It doesn't work either...

I tried just creating a MsgBox on the GotFocus and Enter events, that's not working either... it makes me think that the code isn't being read at all when those events happen...

I don't have to save the code or click some weird "insert code" button or anything after I type my code for it to be applied to the object, do I? I have just been going into the code window, typing the code, then closing the code window... am I missing something else?
 
Sorry, I guess you are using 2007, somehow that didn't register. Make sure you have the location of the database file set as a trusted location (see my last post for the link to how).
 
That was it!

The security warning was refusing to run any code... I just kind of thought that it wouldn't matter in the project and development phase...

Everything works fine now, my original code runs perfectly.

Thanks, guys
 
Glad we could help.
 

Users who are viewing this thread

Back
Top Bottom