Insertion Point Start

  • Thread starter Thread starter kendrad
  • Start date Start date
K

kendrad

Guest
I have a 2 text boxes on a form for a person's First Name and Last Name. I created an Input Mask so that the First letter must be capital. Following the Help files in Access I created the Mask to look like this:
>L<?????????
My problem is, whenever I go to the form and click in the First Name or Last Name Field, the Insertion Point goes to the middle of the box. I assume that is because of the Input Mask. How do I get the cursor to go to the beginning of the text box whenever I clik in there?
 
Me.ActiveControl.SelStart = 0

Unfortunately I've always had to put this in both the GotFocus AND the Click events. For some reason (ha ha) they do not work as documented.
 
I'm not familiar with Me.ActiveControl.SelStart=0

Is this something I type into the OnGot Focus and OnClick in the properties for the control? I tried doing that but got an error message. Or is this a macro I need to create? Thanks for all your help.
 
Why don't you take the input mask off the fields and instead try the strConv function on each field - place it on the AfterUpdate event on the field:

Me.[txtFirstName] = StrConv(Me.[txtFirstName], vbProperCase)



[This message has been edited by Elana (edited 04-09-2002).]
 
Sorry, I assumed too much and didn't explain that this was VBA code.

If you go to the Event tab of Properties for your field, and click the [...] at the end of the GotFocus event, choose Code Builder. Then place that single line of code exactly as written between the open lines that appear. Do the same thing with the Click event, so you'll end up with something like this:
Code:
Private Sub DistrictCode_Click()
    Me.ActiveControl.SelStart = 0
End Sub


Private Sub DistrictCode_GotFocus()
    Me.ActiveControl.SelStart = 0
End Sub

Elana, the reason not to use vbProperCase is because that will mangle names such as MacKinnon, McCartney, etc. kendrad's solution is probably the best simple answer to this thorny issue, IMO. Nevermind that putting something in the AfterUpdate of a field to change the field will send yourself into a code loop.

Good luck,
David R

[This message has been edited by David R (edited 04-09-2002).]
 
Thanks David - you're right about the vbProperCase having limitations with certain names, but placing it on the AfterUpdate event of a control (not the form) is the correct thing to do. I think one runs into trouble with the code if they place it on the Before Update event.

[This message has been edited by Elana (edited 04-09-2002).]
 
Elana - Thanks for the tip. How fascinating that what works for the form as a whole is exactly what does not work for an individual field.

And by 'fascinating', I mean 'stupid'.
biggrin.gif


Hail Microsloth!

David R
 

Users who are viewing this thread

Back
Top Bottom