Dim dbs As DAO.Database
Dim fld As DAO.Field
Dim prp As DAO.Property
Const conErrPropertyNotFound = 3270
' Turn off error trapping.
On Error Resume Next
Set dbs = CurrentDb
' Set field property.
Set fld = dbs.TableDefs!Products.Fields!ProductID
fld.Properties("ColumnHidden") = True
' Error may have occurred when value was set.
If Err.Number <> 0 Then
If Err.Number <> conErrPropertyNotFound Then
On Error GoTo 0
MsgBox "Couldn't set property 'ColumnHidden' " & _
"on field '" & fld.Name & "'", vbCritical
Else
On Error GoTo 0
Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
fld.Properties.Append prp
End If
End If
Set prp = Nothing
Set fld = Nothing
Set dbs = Nothing