Set ws = DBEngine.Workspaces(0) Set dbs = ws.OpenDatabase(gcstrDatabaseFileSpec, True) Set tdf = dbs.TableDefs("Opponent") Set fld = tdf.Fields("OppAbbrev") Call SetPropertyDAO(fld, "Size", dbText, 20, strErrMsg) dbs.Close Set dbs = Nothing The following code is the SetPropertyDAO() function based upon the work of Alan Browne. Note that the HasProperty() function returns true when used in the function. : Public Function SetPropertyDAO(obj As Object, strPropertyName As String, intType As Integer, _ varValue As Variant, Optional strErrMsg As String) As Boolean On Error GoTo ErrHandler 'Purpose: Set a property for an object, creating if necessary. 'Arguments: obj = the object whose property should be set. ' strPropertyName = the name of the property to set. ' intType = the type of property (needed for creating) ' varValue = the value to set this property to. ' strErrMsg = string to append any error message to. If HasProperty(obj, strPropertyName) Then obj.Properties(strPropertyName) = varValue Else obj.Properties.Append obj.CreateProperty(strPropertyName, intType, varValue) End If SetPropertyDAO = True ExitHandler: Exit Function ErrHandler: strErrMsg = strErrMsg & obj.Name & "." & strPropertyName & " not set to " & varValue & _ ". Error " & Err.Number & " - " & Err.Description & vbCrLf Resume ExitHandler End Function
ALTER TABLE Opponent ALTER COLUMN OppAbbrev CHAR(20);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)