Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005

    Unanswered: Control Source vs Default Value

    Whats the difference between Control Source & Default Value? When should you use one instead of the other?

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    wonder what the help system, or heaven forbid even google, has to say on this?

    a default value is the value that will be stored when this record is written to the database if nothing else is typed into the control

    the control source is the column (value) that this control represents from the data.

    Some database tables allow you to set other related properties eg if the column can be null, if it can hold duplicate values and so on

    so a control on a form or report without a control source will have no data - ie the control just "sits" there and does nothing it doens't contain anything, anything you set it to will not be stored, it won't change as you scroll through the recorset. These type of controls are known as unbound controls - they do not have any data column bound (assigned) to them

    a control (OR column) without a default value will store NULL if the users doesn't type anything (assuing that NULL's are allowed for the column in the table definition)

    So the 2 elements are properties of the same control. not all properties are used in all applications. It is possible to set a default value at table / row level (when you define the column in the table) and at form level (when you define the contrl that contains the data element)

    Usually you would nearly always set a control source. Generally is best to set a default property at table level NOT control level. Its rare to set a default property on an unbound control.

    A default value is usually assigned if you want to expressly assign a value rather than a NULL value, and is often used in conjunction with a foreign key.

    An example of where you might want to use a default value is say for example defining a product in your products tables. Your business logic may say that once a product has been captured / recorded it has to go to a third party to be authenticated / validated before it can be made available to the application - eg by setting / clearing a flag. When the product is first entered into the database this flag could have a default value. Say you flag is called IsAuthenticated (ie a true indicates product available, a false indicates details not authenticated). On data capture the flag has a default value of FALSE. You cna replicate some of the default behaviour by putting some code in the before insert event of the form to force values - this can be a better approach especailly if the default value may change depending on one or more conditions in the data. Take the IsAuthenticated flag - say your business requirement had multiple checks/stages to go through (your flag could become a number indicating at what stage the record is in its life (eg state 1:-just added, 2: validated by production, 3: validated by costings 4: released to application, 5: etc.....) Strictly speaking thats not a default value (as a default should only get set once once, on creation - but in some instances it can get changed automatically (ie by default) to a different value

    NULL indicates that there is no valid data for that element at the time the record was created / edited. Some argue that NULL is bad practise and should be designed out of tables.


  3. #3
    Join Date
    Jun 2003
    One interesting thing is that a hardcoded ControlSource such as ="Baseball" means that the control cannot be changed by the user, but a user could easily change the value in a control with a non-blank DefaultValue...
    J. Paul Schmidt, Freelance Web and Database Developer
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts