Roger's Access Library Homepage
Forum Home Forum Home > Other Download Libraries > MS Access MVP Libraries > Tejpal, A.D.
  New Posts New Posts RSS Feed - Form_VirtualTextForNull
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

>
Want a good read? Try The Summer of His Life (available on Amazon!)

Form_VirtualTextForNull

 Post Reply Post Reply
Author
Message
A.D. Tejpal View Drop Down
Microsoft MVP
Microsoft MVP


Joined: 30 Jun 2008
Status: Offline
Points: 192
Post Options Post Options   Thanks (0) Thanks(0)   Quote A.D. Tejpal Quote  Post ReplyReply Direct Link To This Post Topic: Form_VirtualTextForNull
    Posted: 07 Jun 2010 at 10:00am

Form_VirtualTextForNull
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/Form_VirtualTextForNull.zip
 
 
--

Email: adtejpal@gmail.com
Back to Top
Sponsored Links
>
Want a good read? Try The Summer of His Life (available on Amazon!)

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.