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
Solved

How to save the input data format together with the value

Posted on 2001-06-26
6
135 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

860 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