Results 1 to 2 of 2
2005-05-23, 13:44 #1
- Join Date
- Mar 2003
- Thanked 0 Times in 0 Posts
When to use .Value vs .DefaultValue (Access2K)
Can someone please explain the diiferences between Me.DefaultValue and Me.Value. When should I use one instead of the other? Thank you so much.
2005-05-23, 14:05 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: When to use .Value vs .DefaultValue (Access2K)
I don't think you can use either. In the code behind a form or report, Me refers to the active instance of that form or report. Value and DefaultValue are properties of controls, not of a form or report, so Me.Value and Me.DefaultValue don't make sense.
DefaultValue is used to specify the value of a control (or field) in a new record. For example, say that you have a table storing information about clients. One of the fields is Country. If most of your clients are from the USA, it would be nice if the end user doesn't have to enter USA in the Country field. So you set the Default Value of the Country field in the table, or of the Country control on the form bound to the table, to "USA". The Default Value is ONLY used when the user creates a new record, it is not relevant in existing records.
The Value property of a control is the value of the control in the current record. This is the one you usually use in code if you want to check whether the user has entered a valid value etc. Since Value is the default property of a control, you can usually omit it, Me.Country is equivalent to Me.Country.Value.
Post back if you need more information.