Print Page | Close Window

Form_ControlDefaultValues

Printed From: Roger's Access Library
Category: Other Download Libraries
Forum Name: Tejpal, A.D.
Forum Description: A.D. Tejpal's Library
URL: www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=559
Printed Date: 16 Apr 2024 at 10:10am
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: Form_ControlDefaultValues
Posted By: A.D. Tejpal
Subject: Form_ControlDefaultValues
Date Posted: 21 Mar 2011 at 11:57pm

Form_ControlDefaultValues
Explanatory Notes

    This sample db demonstrates programmatic setting of default values for form controls, covering different data types (Date, Text and Number). Two methods are illustrated as follows:
   
1 - Concatenation of intended default value into a string assigned as control's default value property.
    2 - Generation of intended default value through embedded reference within the string assigned as control's default value property.

    For each of the above styles, two alternative modes are demonstrated as follows:
    (a) Set defaults as per current record (On editing or double clicking pertinent controls).
    (b) Set defaults as per last record (On editing or double clicking pertinent controls - only if the cursor is on last record).

    Double click on first column (ID) clears default values for all controls.

    At each stage, the latest record whose values have been used for setting up the defaults, gets highlighted in distinct color. Simultaneously, the new record is highlighted in similar color so as to provide visual correlation. If the current record happens to be other than these two records, it gets highlighted in a separate color.

    For implementing style 1, intended default values are processed through a user defined function so as to take care of appropriate enclosing delimiters for date and text data types, apart from fixing embedded quotes (if any) in text type values. In addition, date type values are properly formatted before concatenation so as to ensure consistent results, despite differing regional settings for short date format. This approach is preferred over the oft adopted simple expedient of merely enclosing the intended default values within outer quotes, irrespective of the data type (as in such a case, it leads to a default value that is not a true live date or number, though the aberration gets masked in case of bound controls).

    Style 2 mentioned above, represents an entirely new approach. It provides appropriate data type in case of dates or numbers, at the same time eliminating the need for worrying about delimiters for date or text type data. Moreover, there is no need for fixing embedded quotes in text type data or for pre-formatting of dates to take care of local regional settings for short date format. This is achieved through an embedded reference within the string assigned as default value. In this context, form level public collection of control values is utilized.

    Note: It would have been much simpler to use embedded reference to the control for setting its default value. However, it is observed that such a technique works only if the reference happens to be to a control other than the one whose default value is being set. For example:  MyControl.DefaultValue = "[SomeOtherControl]"

Version: Access 2000 file format.

References:  Nothing Extra.

Download >>:  http://www.rogersaccesslibrary.com/forum/uploads/37/Form_ControlDefaultValues.zip - uploads/37/Form_ControlDefaultValues.zip


-------------
--

Email: mailto:adtejpal@gmail.com - adtejpal@gmail.com



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net