Need help with VBA Code

DaniBoy

Registered User.
Local time
Today, 21:38
Joined
Nov 18, 2001
Messages
174
Hello,
I have a table that I imported from excel, the tabl name is COList. I have a field on this table called parcel#. The problem that I have is that the parcel number on the file I imported has a dash between numbers. This is the actual format "12345-123-123" and I need it to be without the dashes like this "12345 123 123"

I realy need a code that does this for me.

Can you write it for me?

Thanks
 
Code:
Public Function Repl_Dash(MyStr As String) As String

    Do While InStr(MyStr, "-") <> 0
        MyStr = Left(MyStr, InStr(MyStr, "-") - 1) & " " & Mid(MyStr, InStr(MyStr, "-") + 1)
    Loop
    Repl_Dash = MyStr

End Function

Give this a try
 
Code:
Dim rst as ADODB.RecordSet
 Set rst=New ADODB.RecordSet
  rst.Open "Select * from [TableName]",CurrentProject.Connection,, adOpenDynamic, adLockOptimistic
  Do While Not rst.EOF
   rst.Fields("FieldName")=Replace(rst.Fields("FieldName"),"-"," ")
   rst.update
   rst.movenext
  Loop
 

Users who are viewing this thread

Back
Top Bottom