Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to save the input data format together with the value

Posted on 2001-06-26
6
Medium Priority
?
142 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 200 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

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!

Question has a verified solution.

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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

704 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