Link to home
Start Free TrialLog in
Avatar of andyb7901
andyb7901

asked on

VBA Replace Values

Hi,
Can someone tell me how I would replace a ' in my text field. If I try to update the field it screws up my query! The code I thought I mite use would be something like; (strMessage being my text field name)

         If InStr(strMessage, "'") = 1 Then
                Me("strMessage").Value = Replace(strMessage, "'", " ")
         End If

Woudl this work?
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image


If InStr(me("strMessage"), "'") =1 Then
                Me("strMessage").Value = Replace(Me("strMessage"), "'", " ")
        End If
Replace ' single quote with 2 single quote and all would be fine.
 Me("strMessage").Value = Replace(strMessage, "'", "''")
what value do you want as replacement?

ASKER CERTIFIED SOLUTION
Avatar of Sham Haque
Sham Haque
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial