[AccessD] Trim in Access 2007

Michael R Mattys mmattys at rochester.rr.com
Fri Nov 30 08:36:54 CST 2007


This didn't work either; maybe the table is corrupt?

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("Trimmer", "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 & "])"
        oDB.QueryDefs.Refresh
        DoCmd.SetWarnings False
        DoCmd.SelectObject acQuery, "Trimmer", True
        DoCmd.OpenQuery "Trimmer", acViewNormal
        DoCmd.SetWarnings True
    Next

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

End Function

Michael R. Mattys
MapPoint & Access Dev
www.mattysconsulting.com

----- Original Message ----- 
From: "Michael R Mattys" <mmattys at rochester.rr.com>
To: "Access Developers discussion and problem solving" 
<accessd at databaseadvisors.com>
Sent: Friday, November 30, 2007 9:04 AM
Subject: Re: [AccessD] Trim in Access 2007


>
> Unfortunately, strTmp = Trim(oFld.Value) is invalid in this context.
> Thank you anyway, Patricia. Feel free to try again. I'm stumped.
>
> Michael R. Mattys
> MapPoint & Access Dev
> www.mattysconsulting.com




More information about the AccessD mailing list