>
Part | Description |
variable | A variable declared as an object data type Property. |
object | The variable name of the Database, Field, Index, QueryDef, or TableDef object you want to use to create the new Property object. |
name | A String variable that uniquely names the new Property object. See the Name property for details on valid Property names. |
type | An Integer constant that defines the data type of the new Property object. See the Type property for valid data types. |
value | A Variant variable containing the initial property value. See the Value property for details. |
fDDL | A Boolean variable indicating whether or not the Property is a DDL object. The default is False. If the fDDL is True, this Property object can't be changed or deleted unless the user has dbSecWriteDef permission. |
Dim dbs As Database Set dbs = CurrentDb dbs.Properties!AppTitle = "Northwind Traders"Note You need to create and append only the Microsoft Access properties that apply to data access objects. You can set other Microsoft Access properties in Visual Basic using the standard object.property syntax. Example This example creates a new Property object.
Dim prpPrivilege As Property Dim dbsNorthwind As Database Set dbsNorthwind = DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb") ' Create new Property object. Set prpPrivilege = dbsNorthwind.CreateProperty("Privilege") ' Set other properties of prpPrivilege. prpPrivilege.Type = dbBoolean prpPrivilege.Value = True ' Save Property definition by appending it to Properties collection. dbsNorthwind.Properties.Append prpPrivilegeExample (Microsoft Access) The following example sets the Subject property. The Subject property is a database property that can also be set on the Summary tab of the Database Properties dialog box, available by clicking Database Properties on the File menu. The Subject property applies to a data access object — the SummaryInfo Document object. However, it is defined by Microsoft Access, so the Microsoft Jet database engine does not automatically recognize it. Therefore, you must specifically add this property to the Properties collection of the Document object before you can set it. If the property does not exist in the Properties collection, Microsoft Access will generate an error when you attempt to set it. In the following example, if Microsoft Access generates an error upon trying to set the Subject property, the error-handling routine creates the property and appends it to the Properties collection.
Sub SetAccessProperty() Dim dbs As Database, ctr As Container, doc As Document Dim prp As Property ' Enable error handling. On Error GoTo ErrorHandler ' Return Database variable pointing to current database. Set dbs = CurrentDb ' Return Container variable pointing to Databases container. Set ctr = dbs.Containers!Databases ' Return Document variable pointing to SummaryInfo document. Set doc = ctr.Documents!SummaryInfo ' Attempt to set Subject property. doc.Properties!Subject = "Business Contacts" Exit Sub ErrorHandler: ' Check number of error that has occurred. If Err.Number = 3270 Then ' Create Subject property and set its value. Set prp = doc.CreateProperty("Subject", dbText, _ "Business Contacts") ' Append property. doc.Properties.Append prp ' Resume main procedure. Resume Next Else ' If different error has occurred, display message. MsgBox "Unknown error!", vbCritical End If End Sub