Replace Function

  • Thread starter Thread starter Nigel Bennett
  • Start date Start date
N

Nigel Bennett

I am using a replace function to search for a , in a text
field.

If i update the field and do not have a comma in the field
it deletes the text, if I put a comma in the field then it
will change the comma to a period (good) and leave the
text there.

How do I stop it from deleteing the text if it doesn't
find a comma

Thanks in advance

Nigel
 
Post the code/SQL statement that you're using. I can't envision how Replace
would do this if you're using it correctly.
 
What you posted should not delete the text if there is no comma in the text.
However, there is a minor bug at times with Replace function when you omit
the other arguments in the function's list. Try this and see if it's better:

Me!edinotes = Replace(Me!edinotes, ",", ".", 1, -1, vbTextCompare)

--
----------
Kenneth D. Snell, Ph.D.
Director
Quantum Compliance Systems, Inc.
2111 Golfside Road
Ypsilanti, MI 48197
Ph: 734-572-1000 x122
Fax: 734-572-8815
Email: (e-mail address removed)
Web: www.qcs-facts.com
 
Then I think there's a typo in your code .... the Replace function has six
arguments:
-- the source string
-- the string fragment to be found
-- the string fragment to be used as the replacement
-- the starting position in the source string to start searching
-- the number of string fragments to be replaced
-- the type of match to be done

Check your code and see if you have an extraneous comma somewhere.
 
Thats what I thought also but I am still getting the error

I will work on it

thanks

Nigel
 
Try compacting the database. Also wouldn't hurt to verify that the
references are still ok.

Sometimes, I find I need to reboot the PC when Replace acts up.
 
Back
Top