Solved

Stuffing a formated field

Posted on 2002-07-08
6
160 Views
Last Modified: 2010-05-02

I have a phone number field on a page with the custom format of (@@@) @@@-@@@@. It works fine when reading the data from the database. For instance if I have 5551231234 in the database then (555) 123-1234 is displayed. The problem is when I "stuff" the field with data. If I say txtMyPhone.text = "5551231234" then the text field just displays 5551231234 until I exit and come back into the form. If I stuff it with (555) 123-1234 then it displays properly until I exit the form and come back in. In which case I get something like ((55)5) -123-12.  How can I stuff the field and have it immediatly formated via the current fields format properties?
0
Comment
Question by:bfeddish
[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
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7137768
Instead of stuffing in a text Box, why don't you try writing it in another maskedit box with the same format.

So when you save it, wont that help.

-priya


0
 
LVL 1

Author Comment

by:bfeddish
ID: 7137824

After the user exits the field with a 7 digit number I put in the area code automatically and and I want the field to display to the user properly right after they exit the field.

Bryan
0
 
LVL 1

Expert Comment

by:eeevans
ID: 7137919
What particular edit control are you using.  The one I'm using won't take anything that isn't already formatted.

eeevans
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:bfeddish
ID: 7138051

Regular text box.
0
 
LVL 2

Accepted Solution

by:
priya_pbk earned 75 total points
ID: 7138415
hi bfeddish

I strongly recommend you to use "MaskEditBox". This is just what you require to accomplish your task.

Try doing the following: (I just tried it myself, created a database in Access and made a project in VB)

My table consists of the following:
Table Name:PhoneBook

Coln's:
id:AutoNumber datatype (primary key)
PhoneNumber:Text dataype

Put in 2 dummy records like (555) 123-6666 and (666) 444-2345

----------------------------

For the VB project. Add a Maskedit Box (Reference to Microsoft MaskEdit control 6.0 in Project->Components)and for the database thing, add an Adodc control and connect to your database table(here in my case phoneBook.mdb).

First of all you have gotta format the Maskeditbox. Click the MaskeditBox and press F4 for its properties.

1) Click the "Format" properties and copy this format:
(###) ###-#### or whatever format you wish to have and press enter.

2)Then set the 'Datasource' properties of the MaskEdit Box to 'Adodc1" and the 'DataField' properties to phoneNumber(in this case)

Now press F5 to execute the project to see the records of the database. You can change/edit the records at runtime with the format you wish to save.

I hope I have helped you to a certain extend!

-priya

0
 
LVL 1

Author Comment

by:bfeddish
ID: 7138538

That was it!

Thanks!
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

717 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