-----Original Message-----
Is there a function I can use that will strip out the
dashes in a Social Security number?
.
'Add a field Called CleanSocialSecuritynumber in yout
Table. Under HELP check ASCII characters
'This stripes the punctuation from the
SocialSecuritynumber in the Table "tblYOURNAME"
'& puts the stripped SocialSecuritynumber into the Field
CleanSocialSecuritynumber. If the field is empty then
'it updates the field CleanSocialSecuritynumber to null &
continues to the next SocialSecuritynumber
'As long as the Table & fields exist can be run straight
from a Module.
Private Sub cleanpart11()
Dim rstData As Recordset ' holds records to be
processed
Dim strTmpPart As String ' temp location for RefNo
being processed
Dim iloop As Integer ' loop counter, used to keep
track of position in string
'Turn Acces warnings off
DoCmd.SetWarnings False
'Opens data set for processing
Set rstData = CurrentDb.OpenRecordset
("tblYOURNAME") 'The name of the Table
While Not rstData.EOF
'checks for field 'SocialSecuritynumber'
containing a null
If Not IsNull(rstData.Fields
("SocialSecuritynumber")) Then
'if no null then process field
' get this record SocialSecuritynumber
strTmpPart = rstData.Fields
("SocialSecuritynumber")
iloop = 1
'for each character in SocialSecuritynumber
check for AlphaNumeric
While iloop <= Len(strTmpPart)
'if not an alphanumeric, remove from
string by taking all chars upto and all chars after
If Asc(Mid(strTmpPart, iloop, 1)) < 48 Or
(Asc(Mid(strTmpPart, iloop, 1)) > _
57 And Asc(Mid(strTmpPart, iloop, 1)) <
65) Or (Asc(Mid(strTmpPart, iloop, 1)) _
90 And Asc(Mid(strTmpPart, iloop, 1)) <
97) Or Asc(Mid(strTmpPart, iloop, 1)) > 122 Then
strTmpPart = Left(strTmpPart, iloop - 1) &
Mid(strTmpPart, iloop + 1, Len(strTmpPart))
End If
'next character
iloop = iloop + 1
Wend
' store cleaned SocialSecuritynumber
in 'CleanSocialSecuritynumber' field of dataset
rstData.Edit
rstData.Fields("CleanSocialSecuritynumber") =
strTmpPart
rstData.Update
Else
'If the field is null then strTmpPart is null
End If
' get next record
rstData.MoveNext
Wend
' all records done - close dataset
rstData.Close
End Sub