A family of Microsoft relational database management systems designed for ease of use.
Precisely, when called from ADODB through ODBC.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Replace function won't work on Access 2007 when called in SQL using ADODB.
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Precisely, when called from ADODB through ODBC.
I just ran this test in 2007 SP2:
Dim cnn As ADODB.Connection
Dim strSQL As String
Set cnn = CurrentProject.Connection
strSQL = "SELECT LastName, Replace(LastName,'e','XX') as XFile " _
& "INTO zzzTest " _
& "FROM Employees"
cnn.Execute strSQL
Application.RefreshDatabaseWindow
Set cnn = Nothing
It worked perfectly.
It works with A2010, though:
? CurrentProject.Connection.Execute("SELECT REPLACE('abcdef', 'b', 'z')").Fields(0).Value
azcdef
Replace is no more supported in Access 2007 when called via ADO.
So if you need to do single replacement, handle the same in programing code.
Else if is a mass replacement, you can follow below logic.
LEFT([NAME],INSTR(1,[NAME],'LTD')-1) + 'LIMITED' + MID([NAME],INSTR(1,[NAME],'LTD')+3)
[NAME] being the field 'LTD' being the search string & 'LIMITED' being the replace string.
Drawback of this usage is you have to repeat calls, since each execution will replace only the first occurance of th search string.