Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Los Angeles
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Telephone Area Codes

    ACCESS 2000:
    Is there a way to set a default area code for a field with the telephone type input mask? An weak solution is to make the default value something like 415 000 0000. This is not much help with data entry, because the user has to click past the area code. I'd like it so that when the user tabs to the telephone field, the default area code (first three digits in parens) is filled in, but can be overwritten if needed. The cursor lands past the area code, ready for phone number input. (I've also used a macro that enters the keystrokes for the three digits. This is cool for new entries. Problem is that it fires anytime a user clicks in the field - will overwrite data - area codes that are NOT the default will get wiped out.)

    THANKS,

  2. #2
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Telephone Area Codes

    You could try using a different control for the area code then combine them later when the record is updated.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Telephone Area Codes

    The problem with macros is that you can't control them very well. What you need is a piece of code in the OnEnter event of the control that does what your macro is doing EXCEPT that it tests first to see if there is a value in the field. If there is, it doesn't do anything. If there is no value, it fills in the default area code. It would look something like this (be warned, this is air code and untested):

    <pre>Private Sub txtTelephone_Enter()

    'Test to see if there is anything in the field
    'if there is, do nothing

    If Len([txtTelephone] & "") = 0 Then

    'if the field is empty, then insert the area code
    [txtTelephone]= 415

    'then move to the next position
    [txtTelephone].SelStart = _
    Len([txtTelephone].Text)+1
    End If 'Len([txtTelephone] & "") = 0
    End Sub 'txtTelephone_Enter()</pre>

    Charlotte

  4. #4
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Telephone Area Codes

    Would having the area code as a field separate from the main part be practical? You could then set an area code default value for new records, and then recombine the values in a query.

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Los Angeles
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Telephone Area Codes

    Charlotte

    Your "aircode" worked beautifully. Thanks. The telephone input mask caused some interference - but I figured out that I could change the line:
    Len([txtTelephone].text)+1
    to read:
    Len([txtTelephone].text)-8

    and then it works like a charm.

    Thanks.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Telephone Area Codes

    Told you it was air code! <img src=/S/grin.gif border=0 alt=grin width=15 height=15> Input masks do strange things to functions like Len, and I was guessing. Anyway, glad you got it working.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •