0 like 0 dislike
29 views
in Computer Science by (1.0m points)
What is default value property?

1 Answer

0 like 0 dislike
by (1.0m points)
Specifies a String value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write.

expression.DefaultValue

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks

The DefaultValue property doesn't apply to check box, option button, or toggle button controls when they are in an option group. It does however apply to the option group itself.

The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object.

The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now(), the control displays the current date and time. The maximum length for a DefaultValue property setting is 255 characters.

For a control, you can set this property in the control's property sheet. For a field, you can set this property in table Design view (in the Field Properties section), in a macro , or by using Visual Basic for Applications (VBA) code.

In VBA code, use a string expression to set the value of this property. For example, the following code sets the DefaultValue property for a text box control named PaymentMethod to "Cash":

Forms!frmInvoice!PaymentMethod.DefaultValue = """Cash"""

Note: To set this property for a field by using VBA code, use the ADO DefaultValue property or the DAO DefaultValue property.

The DefaultValue property is applied only when you add a new record. If you change the DefaultValue property, the change isn't automatically applied to existing records.

If you set the DefaultValue property for a form control that's bound to a field that also has a DefaultValue property setting defined in the table, the control setting overrides the table setting.

If you create a control by dragging a field from the field list, the field's DefaultValue property setting, as defined in the table, is applied to the control on the form although the control's DefaultValue property setting will remain blank.

One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

=Forms!frmInvoice!txtShipTo

If the controls are on the same form, the control that is the source of the default value must appear earlier in the tab order than the control containing the expression.

Related questions

0 like 0 dislike
1 answer 20 views
0 like 0 dislike
0 answers 45 views
0 like 0 dislike
1 answer 28 views
asked Feb 13, 2019 in Computer Science by danish (1.0m points)
0 like 0 dislike
1 answer 22 views
asked Feb 13, 2019 in Computer Science by danish (1.0m points)
0 like 0 dislike
1 answer 26 views
asked Feb 12, 2019 in Computer Science by danish (1.0m points)
0 like 0 dislike
1 answer 20 views
asked Feb 11, 2019 in Computer Science by danish (1.0m points)
0 like 0 dislike
1 answer 81 views
0 like 0 dislike
1 answer 31 views
0 like 0 dislike
1 answer 36 views
0 like 0 dislike
1 answer 41 views
Welcome to Free Homework Help, where you can ask questions and receive answers from other members of the community. Anybody can ask a question. Anybody can answer. The best answers are voted up and rise to the top. Join them; it only takes a minute: School, College, University, Academy Free Homework Help

19.4k questions

18.3k answers

8.7k comments

3.3k users

Free Hit Counters
...