ACC2000: How to Replace a String with Another String
ID: Q210465
|
The information in this article applies to:
Novice: Requires knowledge of the user interface on single-user computers.
SUMMARY
This article shows you how to replace one string with another string.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the
following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
MORE INFORMATION
If you wanted to replace one string with another string in earlier versions of Microsoft Access, you had to create a user-defined function to accomplish the task. Access 2000 supplies that functionality for you with the Replace() function. To replace one string with another string, follow these steps:
- Create a module and type the following line in the Declarations
section if it is not already there:
Option Explicit
- Type the following procedure:
Sub TestReplace()
Dim strPhrase As String
Dim strOldWord As String
Dim strNewWord As String
strPhrase = "Microsoft Access 97"
strOldWord = "97"
strNewWord = "2000"
strPhrase = Replace(strPhrase, strOldWord, strNewWord, 1, -1)
MsgBox strPhrase
End Sub
- To test this function, type the following line in the Immediate window, and then press ENTER:
TestReplace
Note that the following message is displayed:
Microsoft Access 2000
REFERENCES
For more information about the Replace() Function, click Microsoft Access Help on the
Help menu, type "Replace Function" in the Office Assistant or the Answer Wizard,
and then click Search to view the topic.
Additional query words:
substitute
Keywords : kbprg kbdta AccCon KbVBA
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbinfo