Print Page | Close Window


Printed From: Roger's Access Library
Category: Other Download Libraries
Forum Name: Tejpal, A.D.
Forum Description: A.D. Tejpal's Library
Printed Date: 16 Jul 2018 at 12:09pm

Topic: Form_VirtualTextForNull
Posted By: A.D. Tejpal
Subject: Form_VirtualTextForNull
Date Posted: 07 Jun 2010 at 10:00am

Explanatory Notes

    In certain situations, it might be considered desirable to display a meaningful text in a form control in case of Null value,  without compromising the Null value status (which would otherwise stand vitiated by assignment of a default value).

    This sample db demonstrates a simple technique for achieving the above objective. This is done by manipulation of control's format property and has the advantage that the required information gets displayed without disturbing the value actually held by the control (i.e. Null or otherwise).

    Either of the following styles can be used for assigning the format property:
    (a) Direct Entry against format property on format tab in control's property sheet via user interface at design time:
         @;"[Text To Be Displayed If Null]" 

    (b) Programmatic assignment via code in form's VBA module:
         Me.MyCombo.Format = "@;[Text To Be Displayed If Null]"

    With the above approach, whenever the control happens to be blank, it will display the desired virtual text. In this state, if the user clicks into the control, the virtual text disappears, making it very convenient to make a new entry.

    In case of a combo box where first column is not hidden, direct assignment as per (a) above is found adequate. However, very often, the first column width is kept zero. In that case, for proper effect, it is found necessary to manipulate the format property via code.

    In this sample db, demos are provided for the following:
    (a) Combo box with first column hidden.
    (b) Combo box with first column on display.
    (c) Text box meant for entering dates: This involves toggling of formats. Virtual text message ([Enter Target Date]) gets displayed if the text box is blank. On the other hand, when a date is entered, the format gets switched to long date with a meaningful prefix. Typical display:  "Target Dt:  December 31, 2010". It is to be noted that inclusion of an informative prefix in this manner does not disturb the value held by the control in question. It continues to be a proper date.
    (d) Subform displaying meaningful virtual text on the new record.

Version:  Access 2000 File Format

Reference:  Nothing Extra

Download >>: - uploads/37/


Email: -

Print Page | Close Window