Solved

Setting cursor in phone number field (text box)

Posted on 2014-02-18
3
376 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
  • 2
3 Comments
 
LVL 34

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now