How to remove dashes "-" from the data in a table column in ms-access

D

dhiman2002

Hi,
One of the columns in my table in msaccess has data like :
ASD-DFG-SDF
QWE-IOP-JKK

I need to remove the dashes "-" from the data.

Please help.

thx,
Dhiman
 
D

Duane Hookom

Open the table in datasheet view and place your cursor in the column. Then
select Edit->Replace to find - and replace with nothing. Choose any part of
the field.
 
D

dhiman2002

I need to do it through code...

thx
Dhiman

Duane said:
Open the table in datasheet view and place your cursor in the column. Then
select Edit->Replace to find - and replace with nothing. Choose any part of
the field.
 
D

dhiman2002

I need to do it through code...

thx
Dhiman

Duane said:
Open the table in datasheet view and place your cursor in the column. Then
select Edit->Replace to find - and replace with nothing. Choose any part of
the field.
 
A

Allen Browne

Use the Replace() function in an Update query statement:

Dim strSql As String
strSql = "UPDATE MyTable SET MyField = Replace([MyField] ""-"", """");"
dbEngine(0)(0).Execute strSql, dbFailOnError
 
D

Duane Hookom

I missed the "code" part in your original posting ;-)
Try code like

Sub ReplaceHyphens()
Dim strSQL As String
strSQL = "UPDATE tblNoNameGiven SET FieldNoName =
Replace(FieldNoName,'-','')"
CurrentDb.Execute strSQL, dbFailOnError
End Sub

The code will depend on your table and field names.
 
D

dhiman2002

Its throwing the error:
"Undefined Function "Replace" in expression


thx Dhiman
 
D

dhiman2002

Its throwing the error:
"Undefined Function "Replace" in expression


thx Dhiman
 
D

Duane Hookom

This could be due to your version and service pack of Office/Access. You may
need to update your system or create a wrapper function:

Public Function ReplaceIt(strText as String, strFind as String, strWith as
String) as String
ReplaceIt = Replace(strText, strFind, strWith)
End Function

Then use ReplaceIt() in place of Replace().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top