Freigeben über


Field2.Required-Eigenschaft (DAO)

Gilt für: Access 2013, Office 2013

Mit dieser Eigenschaft wird ein Wert festgelegt oder zurückgegeben, der angibt, ob ein Field2-Objekt einen Nicht-Nullwert erfordert.

Syntax

Ausdruck . Erforderlich

Ausdruck Eine Variable, die ein Field2-Objekt darstellt.

Hinweise

Bei einem Field2-Objekt, das der Fields-Auflistung noch nicht angefügt wurde, besteht für diese Eigenschaft Lese-/Schreibzugriff.

Die Verfügbarkeit der Required-Eigenschaft hängt vom Objekt ab, in dem die Fields -Auflistung enthalten ist (siehe folgende Tabelle).

Zugehörigkeit der Fields-Auflistung

Required-Wert

Index-Objekt

Nicht unterstützt

QueryDef-Objekt

Schreibgeschützt

Recordset-Objekt

Schreibgeschützt

Relation-Objekt

Nicht unterstützt

TableDef-Objekt

Lesen/Schreiben

You can use the Required property along with the AllowZeroLength, ValidateOnSet, or ValidationRule property to determine the validity of the Value property setting for that Field2 object. If the Required property is set to False, the field can contain null values as well as values that meet the conditions specified by the AllowZeroLength and ValidationRule property settings.

Hinweis

[!HINWEIS] Wenn Sie diese Eigenschaft für ein Index-Objekt oder ein Field2-Objekt festlegen können, legen Sie sie für das Field2-Objekt fest. Die Gültigkeit der Eigenschafteneinstellung für ein Field2-Objekt wird vor der eines Index-Objekts überprüft.

Beispiel

This example uses the Required property to report which fields in three different tables must contain data in order for a new record to be added. The RequiredOutput procedure is required for this procedure to run.

Sub RequiredX() 
 
 Dim dbsNorthwind As Database 
 Dim tdfloop As TableDef 
 
 Set dbsNorthwind = OpenDatabase("Northwind.mdb") 
 
 With dbsNorthwind 
 ' Show which fields are required in the Fields 
 ' collections of three different TableDef objects. 
 RequiredOutput .TableDefs("Categories") 
 RequiredOutput .TableDefs("Customers") 
 RequiredOutput .TableDefs("Employees") 
 .Close 
 End With 
 
End Sub 
 
Sub RequiredOutput(tdfTemp As TableDef) 
 
 Dim fldLoop As Field2 
 
 ' Enumerate Fields collection of the specified TableDef 
 ' and show the Required property. 
 Debug.Print "Fields in " & tdfTemp.Name & ":" 
 For Each fldLoop In tdfTemp.Fields 
 Debug.Print , fldLoop.Name & ", Required = " & _ 
 fldLoop.Required 
 Next fldLoop 
 
End Sub