Solved

How to save the input data format together with the value

Posted on 2001-06-26
6
138 Views
Last Modified: 2010-05-02
I use Text control and ADO Control (Add new, update) to input data. I want to have the data to save in the MS Access by format such as X-XXX-XX. But I don't want users to input the "-". How can I write the data into database by using the format I define in the Text Control? But not to write a program, is there any property or parameter to do that?
0
Comment
Question by:rydv
[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
  • 2
  • 2
  • 2
6 Comments
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6229979
Hmmm... I've got no idea on how to really do that as I do not really know the format.

You may want to try using the Instr() function or the Left() function.

An example of the Left() and Instr() function:

MsgBox Left("This is the day", 4)

- Returns 4

MsgBox InStr(1, "This is the day", "the")

- Returns 9

If they're all numbers, you could also try using the Format() function.

Another function you might need is the Mid function which returns a specific number of characters:

Dim FirstLetter As Integer, LastLetter As Integer
FirstLetter = 1
LastLetter = 4

MsgBox Mid("This is the day", 1, 4)

- Returns "This"

That's it!

glass cookie : )
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6229987
Some way to do it is to scan the string in the textbox, split them up and then add he  "-" together.  Something like this:

MyInput = Segment1 + "-" + Segment2 + "-"...

On the other hand, there might be a better way, so... good luck on finding a better answer!

That's it!

glass cookie : )
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6230070
rydv

You are probably going to have to write a little code.  In the LostFocus event for the text box in question, use something similar to the following:

Private Sub Text1_lostfocus()
  Text1.Text = Format(Text1.Text, "#-###-###-#")
End Sub

substituting your format for the one I show.  When the user leaves the field, the field's contents are replaced with the new contents which will include the dashes.
0
Independent Software Vendors: 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!

 

Author Comment

by:rydv
ID: 6230171
Thanks for reply. DRRYAN3.

This TEXT control has been bounded to datasource and datafields. I checked and found that the text format is correct during debug, but I don't understand why "-" missing in the database...
0
 

Author Comment

by:rydv
ID: 6230283
use format function to assign to the field before running the UPDATE.
0
 
LVL 12

Accepted Solution

by:
DRRYAN3 earned 50 total points
ID: 6231704
Where are you applying the format?  Which of the text control's properties or events are you using to reformat the entered data?
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

624 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