mattkorguk
Registered User.
- Local time
- Today, 21:45
- Joined
- Jun 26, 2007
- Messages
- 301
Hi All,
I've put the following Function together to clear out unwanted bits before exporting as csv. I was just wondering if there's a way of holding the table names together with a total count of each item replaced? I wasn't sure if these were stored and could be returned?!
Suggestions welcomed.
Cheers
Matt
I've put the following Function together to clear out unwanted bits before exporting as csv. I was just wondering if there's a way of holding the table names together with a total count of each item replaced? I wasn't sure if these were stored and could be returned?!
Suggestions welcomed.
Cheers
Matt
Code:
Public Function ClearCommas()
On Error GoTo ClearErr
Dim db As DAO.Database
Dim tb As DAO.TableDef
Dim fld As DAO.Field
Dim strSQL As String
Dim strSQL2 As String
Dim strSQL3 As String
Set db = CurrentDb
For Each tb In db.TableDefs
If tb.Name = "Client" Or _
tb.Name = "Dependants" Or _
tb.Name = "Plan" Or _
tb.Name = "Tasks" _
Then
For Each fld In tb.Fields
DoCmd.SetWarnings False
strSQL = "UPDATE [" & tb.Name & "] SET [" & fld.Name & "] = Replace([" & fld.Name & "],',','');"
strSQL2 = "UPDATE [" & tb.Name & "] SET [" & fld.Name & "] = Replace([" & fld.Name & "],Chr(10),' ');"
strSQL3 = "UPDATE [" & tb.Name & "] SET [" & fld.Name & "] = Replace([" & fld.Name & "],Chr(13),'');"
DoCmd.RunSQL strSQL
DoCmd.RunSQL strSQL2
DoCmd.RunSQL strSQL3
DoEvents
Next fld
End If
DoCmd.SetWarnings True
Next tb
Exit Function
ClearErr:
If Err.Number = 3709 Or Err.Number = 3113 Or Err.Number = 3073 Then
Resume Next
Else
MsgBox Err.Number & " / " & Err.Description
Resume Next
End If
End Function