Solved

Setting cursor in phone number field (text box)

Posted on 2014-02-18
3
388 Views
Last Modified: 2014-03-02
I have an Access 2007 form, which contains a text box represented in a phone number format, e.g.

!\(999")"000\-0000

If the field is empty, I would like the cursor to be placed at the beginning of the field.
If the field contains a phone number, I would like the cursor to remain where the user clicked the field.

How would I go about doing this?

Thanks...Tom
0
Comment
Question by:tpigielski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 37

Expert Comment

by:PatHartman
ID: 39867916
I'm not sure you can control that.  The input mask gets in the way of normal data entry.  You can try changing the "Behavior on entering field" property in  file/options/client settings but I'm not sure that would help.  I like it to select all when the user tabs into a field.  The problem is that this setting is universal so changing it changes it for EVERY database.
0
 

Accepted Solution

by:
tpigielski earned 0 total points
ID: 39886837
This in fact can be controllable.  Here is the code that I used to do this:

Private Sub txtPrimaryPhone_Click()

  If txtPrimaryPhone.Tag = True Then
    txtPrimaryPhone.Tag = False
    txtPrimaryPhone.SelStart = 0
    txtPrimaryPhone.SelLength = 0
  End If
 
End Sub

Private Sub txtPrimaryPhone_GotFocus()

    txtPrimaryPhone.Tag = True
    txtPrimaryPhone.SelStart = 0
    txtPrimaryPhone.SelLength = 0
   
End Sub

Private Sub txtPrimaryPhone_KeyUp(KeyCode As Integer, Shift As Integer)

    txtPrimaryPhone.Tag = False
   
End Sub
0
 

Author Closing Comment

by:tpigielski
ID: 39898363
Other answer did not solve my problem.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question