• When to use .Value vs .DefaultValue (Access2K)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » When to use .Value vs .DefaultValue (Access2K)

    • This topic has 1 reply, 2 voices, and was last updated 20 years ago.
    Author
    Topic
    #419885

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #949266

      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.

    Viewing 0 reply threads
    Reply To: Reply #949266 in When to use .Value vs .DefaultValue (Access2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel