Solved

Stuffing a formated field

Posted on 2002-07-08
6
157 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 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