Solved

Stuffing a formated field

Posted on 2002-07-08
6
155 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

929 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

14 Experts available now in Live!

Get 1:1 Help Now