Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTPicker control - Default to Null

Status
Not open for further replies.

Orion45

IS-IT--Management
Feb 6, 2002
155
US
I am using an ActiveX DTPicker control to allow the user to add new dates to the database. However, when the screen opens I want the date fields to be blank so that the user is forced to select a date. The problem is I have not been able to find a way for the DtPicker to display a null value. I do not want to use this check box property of this control because that might imply to the user that the field is optional, which it isn't.
Does anyone know how to default a DtPicker to Null? Thanks!
 
I ran into the same problem the first time I used the DTPicker control (I don't like the checkbox either).

One way to use it is to leave it unbound and update your date field using VBA in the form's BeforeUpdate() event. The problem is the control always shows a date whether the user has selected one or not, so trying to synchronize the date field with the control takes some work. In the form's Current() event, I check to see whether it's a new record or the field is null, then set the control to a default value, such as today's date or whatever. You also have to monitor the Change() event of the picker to see whether the user is changing existing values.

An alternate method would be to add the DTPicker control next to or under the bound date field textbox, and let the user pick a date, and provide a small command button they could click to update the bound date field with the DTPicker's value - much simpler, and you could more easily tell if the field was null.

I've also done something similar by adding a small button with an ellipsis caption (...) on it next to each date field, which the user clicks to open a custom form with a DTPicker or calendar control on it. The button_click() event opens the form modally and after the user clicks OK, which just hides the form instead of closing it, the field can be updated with the hidden form's calendar value. The benefit here is you only have to setup the custom form once and it can be reused anywhere in your app that you need a date, just by adding a small button next to the textbox.

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top