[AccessD] Trim in Access 2007

Gustav Brock Gustav at cactus.dk
Fri Nov 30 09:05:58 CST 2007


Hi Michael

Ignoring Trim for a moment, why not just execute a temporary query:

Function TrimCass()

    Dim oDB As DAO.Database
    Dim oTbl As DAO.TableDef
    Dim oQry As DAO.QueryDef
    Dim oFld As DAO.Field

    Dim strTmp As String
    Dim strSql As String

    Set oDB = CurrentDb
    Set oQry = oDB.CreateQueryDef("", "SELECT * FROM CASS")
    Set oTbl = oDB.TableDefs("CASS")

    For Each oFld In oTbl.Fields
        oQry.SQL = "UPDATE CASS SET CASS.[" & oFld.Name & "] = Trim([" & oFld.Name & "])"
        oQry.Execute
    Next

    Set oFld = Nothing
    Set oTbl = Nothing
    Set oQry = Nothing
    Set oDB = Nothing

End Function

/gustav





More information about the AccessD mailing list