Solved

Format user data from a InputBox

Posted on 2007-11-23
7
1,136 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 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 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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

776 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