Trimming Characters!

Martian262002

New member
Local time
Today, 03:51
Joined
Apr 19, 2006
Messages
7
Hello Everyone,

I have a problem with a couple of my fields in Access 03'. I need to cut the character(chr) out of a number in a field. There is a the little box Chr at the beginning of my PatID numbers and between the 1st number and the 3rd.
The * reresents the little box Chr!!!!!!!!!!!
Ex:1
PatientID
*19742
AND
1*9742

I also have that little box in front of some dates in my dates field.
Ex:2
Dates
5*3/12/2004
I don't need the 5*- Just the date after it!

Is there a way I can Trim/cut these characters out of my fields?????
Please Help!!!!

Thanks,

Martian26
 
You can use the mid, Right, and Left functions
 
Find and Replace

There is a very cool function writen by Alden Streeter that will sort your problem out.

Code:
Function FindAndReplace(ByVal strInString As String, _
        strFindString As String, _
        strReplaceString As String) As String
Dim intPtr As Integer
    If Len(strFindString) > 0 Then  'catch if try to find empty string
        Do
            intPtr = InStr(strInString, strFindString)
            If intPtr > 0 Then
                FindAndReplace = FindAndReplace & left(strInString, intPtr - 1) & _
                                        strReplaceString
                    strInString = Mid(strInString, intPtr + Len(strFindString))
            End If
        Loop While intPtr > 0
    End If
    FindAndReplace = FindAndReplace & strInString
End Function

Past the Field value the caracter that you want to replace and the value of the replacmet caracter to the functioin and you are done :)

Check out the sample I have posted.
Let us know how you get on.

Good luck mate :)
 

Attachments

It Works!

Thanks,

It worked great, I really appreciate it!!

Thanks again everyone,:)

Martian26:cool:
 

Users who are viewing this thread

Back
Top Bottom