When I try this, it gives me an error... "Undefinded 'Replace' in expression"
fredg said:
I need to remove dashes "-" from a field:
My data looks like this: 111-11-1111 and I need it to look like this:
111111111. I've been told that I need to use an update query with the
Replace function. I have very little programming experience and I've been
unable to find any examples of this function. Can someone show me what
specifically I would have to type to make the replace function work for the
situation I've outlined and/or cite a place where I can find examples of this
function so that I may teach myself?
Thanks in advance
You wish to permanently change the data?
Are you sure it's not simply an Input Mask that is adding the hyphens,
while the data is actually stored without hyphens?
If the data does indeed have hyphens, then if you have a later version
of Access 2000 or newer.....
Back Up your current data.
Create a New Query.
Copy and Paste this into the Query's SQL Window.
Change the Table and Field Names as needed.
Update YourTable Set YourTable.[FieldName] =
Replace([FieldName],"-","");
Do you have Access 2000 or newer?
Some earlier versions of Access 2000 require that you create a user
defined function (in a module) then call that function from the query.
Function ReplaceText(StringIn as String) as String
ReplaceText = Replace([StringIn],"-","")
End Function
Then call it from the query:
Update YourTable Set YourTable.[FieldName] = ReplaceText([FieldName]);
Newer Access 2000 as well as 2002, 2003, you can use Replace directly
in the query..
If this still throws an error, check your references.
Open any module in Design view (or click Ctrl + G).
On the Tools menu, click References.
Click to clear the check box for the type library or object library
marked as "Missing:."
An alternative to removing the reference is to restore the referenced
file to the path specified in the References dialog box. If the
referenced file is in a new location, clear the "Missing:" reference
and create a new reference to the file in its new folder.
See Microsoft KnowledgeBase articles:
283115 'ACC2002: References That You Must Set When You Work with
Microsoft Access'
Or for Access 97:
175484 'References to Set When Working With Microsoft Access' for
the correct ones needed,
and
160870 'VBA Functions Break in Database with Missing References' for
how to reset a missing one.
For even more information, see
http://www.accessmvp.com/djsteele/AccessReferenceErrors.html