Answered by:
replace() function does't work

Question
-
Hi
I am using Ms Access 2016 on Wwindows 10 ent.
I have a problem with function Replace(). It doesn't work and the error is “Error run-time 5”.
The same Ms Access vba program on another computer works very well.
Someone can help me?
Marco Dell'Oca
- Edited by Marco Dell'Oca Wednesday, December 19, 2018 7:55 PM
Wednesday, December 19, 2018 7:54 PM
Answers
-
I have a problem with function Replace(). It doesn't work and the error is “Error run-time 5”.
Hi Marco,
How did you call the function? Probably you used some wrong argument(s).
Imb.
- Marked as answer by Marco Dell'Oca Thursday, December 20, 2018 3:02 PM
Wednesday, December 19, 2018 8:19 PM -
Check you references, I have found this corrects errors with basic Access functions
- Marked as answer by Marco Dell'Oca Thursday, December 20, 2018 3:02 PM
Wednesday, December 19, 2018 9:22 PM -
Can you show us your code please.
Typically, when fundamental functions (right, left, mid, ...) don't work it is because of a reference issue. In the VBE, look at your references (under Tools) and see if any are listed as MISSING, if so, fix them and try again.
Daniel Pineault, 2010-2018 Microsoft MVP
Professional Support: http://www.cardaconsultants.com
MS Access Tips and Code Samples: http://www.devhut.net- Marked as answer by Marco Dell'Oca Thursday, December 20, 2018 3:02 PM
Wednesday, December 19, 2018 10:26 PM
All replies
-
I have a problem with function Replace(). It doesn't work and the error is “Error run-time 5”.
Hi Marco,
How did you call the function? Probably you used some wrong argument(s).
Imb.
- Marked as answer by Marco Dell'Oca Thursday, December 20, 2018 3:02 PM
Wednesday, December 19, 2018 8:19 PM -
Check you references, I have found this corrects errors with basic Access functions
- Marked as answer by Marco Dell'Oca Thursday, December 20, 2018 3:02 PM
Wednesday, December 19, 2018 9:22 PM -
Can you show us your code please.
Typically, when fundamental functions (right, left, mid, ...) don't work it is because of a reference issue. In the VBE, look at your references (under Tools) and see if any are listed as MISSING, if so, fix them and try again.
Daniel Pineault, 2010-2018 Microsoft MVP
Professional Support: http://www.cardaconsultants.com
MS Access Tips and Code Samples: http://www.devhut.net- Marked as answer by Marco Dell'Oca Thursday, December 20, 2018 3:02 PM
Wednesday, December 19, 2018 10:26 PM -
Thanks to everybody
No reference mismatch,
No wrong arguments
this is the program part:
Public Function streplace(stringa As String) As String
Dim sost As String
sost = Replace(stringa, "'", "''")
streplace = sost
End Function
Also the same Ms Access vba program on another computer works very well.
I will reinstall MS Office 2016.
Marco Dell'Oca
Thursday, December 20, 2018 3:01 PM -
this is the program part:
Hi Marco,
You can even shorten the code:
Public Function streplace(stringa As String) As String streplace = Replace(stringa, "'", "''") End Function
Imb.Thursday, December 20, 2018 5:26 PM