Share via

Replace function won't work on Access 2007 when called in SQL using ADODB

Anonymous
2011-04-01T09:08:18+00:00

Replace function won't work on Access 2007 when called in SQL using ADODB.

Microsoft 365 and Office | Access | For home | Windows

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.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2015-06-17T08:53:18+00:00

    Precisely, when called from ADODB through ODBC.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-04-01T14:56:18+00:00

    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.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-04-01T12:43:39+00:00

    It works with A2010, though:

    ? CurrentProject.Connection.Execute("SELECT REPLACE('abcdef', 'b', 'z')").Fields(0).Value

    azcdef

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-04-01T09:11:47+00:00

    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.

    Was this answer helpful?

    0 comments No comments