?
Solved

Format user data from a InputBox

Posted on 2007-11-23
7
Medium Priority
?
1,167 Views
Last Modified: 2010-04-21
I have an input box for a user to enter a social security number.  I would like to format the user input to: XX-XX-XXXX

Is this possible?

Thank you.

sUSocSec = InputBox("Please enter full patient Social Security Number:" & vbCrLf & "Format (XX-XX-XXXX)", "Social Security Number")
0
Comment
Question by:thandel
[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
  • 4
  • 2
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20339760
try this

sUSocSec = Format(InputBox("Please enter full patient Social Security Number:" & vbCrLf & "Format (XX-XX-XXXX)", "Social Security Number"), "##-##-####")
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 1000 total points
ID: 20339762
rather than asking the user to properly format the entry, you should allow the user to enter 9 digits, then verify that what the entered was in fact 9 numeric digits, and if so, then format the result as you need>

ALso, using an Input Box is not a good idea.  You would be better served to design your own form, and use that instead.  But with the Input Box:


Dim strSSN As String
strSSN = ""
Do Until Len(strSSN) = 9 And IsNumeric(strSSN)
    strSSN = InputBox("Please enter full patient Social Security Number:", "Social Security Number")
Loop
 
strSSN = Left(strSSN, 3) & "-" & Mid(strSSN, 4, 2) & "-" & Right(strSSN, 4)
 
 
AW

Open in new window

0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 20339826
you can remove the format instruction from the input box so the user will just enter the numbers



sUSocSec = Format(InputBox("Please enter full patient Social Security Number:", "Social Security Number"), "##-##-####")
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:thandel
ID: 20339876
Hmmm Arthur interestin... however pressing cancel doesn't take the user out of this... how can the cancel button stop the loop?
0
 

Author Comment

by:thandel
ID: 20339879
Opps I added this... let me do more testing.

If strSSN = "" Then GoTo Exit_Err_SubmitCA_Click
0
 

Author Comment

by:thandel
ID: 20339915
Here is what I"m testing with..... so far its working nicely.

        Do Until Len(strSSN) = 9 And IsNumeric(strSSN)
            strSSN = InputBox("Please enter patient Social Security Number" & vbCrLf & _
            "(without dashes)", "Social Security Number")
            If strSSN = "" Then GoTo Exit_Err_SubmitCA_Click
        Loop
        strSSN = Left(strSSN, 3) & "-" & Mid(strSSN, 4, 2) & "-" & Right(strSSN, 4)
        Me.Notes = "Social Security Number: " & strSSN & vbCrLf & vbCrLf & Me.Notes
0
 

Author Closing Comment

by:thandel
ID: 31410676
Thanks, I split the points up a bit as both solutions answered my question.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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