Solved

How to save the input data format together with the value

Posted on 2001-06-26
6
132 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:rydv
Comment Utility
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
Comment Utility
use format function to assign to the field before running the UPDATE.
0
 
LVL 12

Accepted Solution

by:
DRRYAN3 earned 50 total points
Comment Utility
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

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

Join & Write a Comment

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…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

744 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

16 Experts available now in Live!

Get 1:1 Help Now