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

  • Thread starter Thread starter dhiman2002
  • Start date Start date
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
 
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.
 
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.
 
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.
 
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
 
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.
 
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().
 
Back
Top