Solved

Stuffing a formated field

Posted on 2002-07-08
6
154 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
Comment Utility
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
Comment Utility

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
Comment Utility
What particular edit control are you using.  The one I'm using won't take anything that isn't already formatted.

eeevans
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:bfeddish
Comment Utility

Regular text box.
0
 
LVL 2

Accepted Solution

by:
priya_pbk earned 75 total points
Comment Utility
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
Comment Utility

That was it!

Thanks!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

10 Experts available now in Live!

Get 1:1 Help Now