Hi,
I have an access table with records and each record has an entry like 001#AKA. I want to remove all the characters on the left of #(inclusive #). I am using this code as an Module in Access to find the # and then doing the replacement. But it seems to be going in a loop and not doing anything. Please can you let me know what could be the problem.
Thanks
Here is my code
Sub main()
Dim ws As Workspace
Dim db As Database
Dim rsMyRS As Recordset
Dim str_rep As String
Dim txt As String
Dim fieldvalue As String
Dim x As String
Dim replacementstring As String
'Set ws = DBEngine.Workspaces(0)
Set db = OpenDatabase("C:\db1.mdb")
Set rsMyRS = db.OpenRecordset("Test", dbOpenDynaset)
fieldvalue = "001#"
If Not rsMyRS.EOF Then rsMyRS.MoveFirst
Do While Not rsMyRS.EOF
x = InStr(1, fieldvalue, "#")
replacementstring = Left(fieldvalue, x)
fieldvalue = Replace(fieldvalue, replacementstring, "")
Loop
End Sub
I have an access table with records and each record has an entry like 001#AKA. I want to remove all the characters on the left of #(inclusive #). I am using this code as an Module in Access to find the # and then doing the replacement. But it seems to be going in a loop and not doing anything. Please can you let me know what could be the problem.
Thanks
Here is my code
Sub main()
Dim ws As Workspace
Dim db As Database
Dim rsMyRS As Recordset
Dim str_rep As String
Dim txt As String
Dim fieldvalue As String
Dim x As String
Dim replacementstring As String
'Set ws = DBEngine.Workspaces(0)
Set db = OpenDatabase("C:\db1.mdb")
Set rsMyRS = db.OpenRecordset("Test", dbOpenDynaset)
fieldvalue = "001#"
If Not rsMyRS.EOF Then rsMyRS.MoveFirst
Do While Not rsMyRS.EOF
x = InStr(1, fieldvalue, "#")
replacementstring = Left(fieldvalue, x)
fieldvalue = Replace(fieldvalue, replacementstring, "")
Loop
End Sub