Solved

Format user data from a InputBox

Posted on 2007-11-23
7
1,111 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
  • 4
  • 2
7 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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 250 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

746 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

13 Experts available now in Live!

Get 1:1 Help Now