tech on the net
Home About Us Feedback Site Map

Microsoft

Access Excel Word

Database

SQL Oracle / PLSQL SQL Server MySQL MariaDB PostgreSQL

Web Development

HTML CSS Color Picker

Language

C Language

More

ASCII Table Linux UNIX Java Clipart Joke of the Moment
Share this page:

MS Access: Replace Function

Learn how to use the Access Replace function with syntax and examples.

Description

The Microsoft Access Replace function replaces a sequence of characters in a string with another set of characters (a number of times).

Syntax

The syntax for the Microsoft Access Replace function is:

Replace ( string1, find, replacement, [start, [count, [compare]]] )

Parameters or Arguments

string1 is the string to replace a sequence of characters with another set of characters.

find is the string that will be searched for in string1.

replacement will replace find in string1.

start is optional. This is the position in string1 to begin the search. If this parameter is omitted, the Replace function will begin the search at position 1.

count is optional. This is the number of occurrences to replace. If this parameter is omitted, the Replace function will replace all occurrences of find with replacement.

compare is optional. This can be one of the following values:

Parameter Value Description
vbUseCompareOption Compares based on the Option Compare statement
vbBinaryCompare Binary comparison
vbTextCompare Textual comparison
vbDatabaseCompare Performs a comparison based on information in your database

Applies To

The Replace function can be used in the following versions of Microsoft Access:

Example

Replace("alphabet", "bet", "hydro") would return "alphahydro"
Replace ("alphabet", "a", "e") would return "elphebet"
Replace("alphabet", "a", "e", 2) would return "lphebet"
Replace("alphabet", "a", "e", 1, 1) would return "elphabet"

Example (in VBA Code)

The Replace function can be used in VBA code in Microsoft Access. For example:

Dim LResult As String

LResult = Replace ("alphabet", "a", "e")

In this example, the variable called LResult would now contain the value "elphebet".

Example (in SQL/Queries)

You can also use the Replace function in a query in Microsoft Access.

Microsoft Access