Default a Time Field if Date is entered

  • Thread starter Thread starter Kaylen
  • Start date Start date
K

Kaylen

I want to know what to do if I want the Time field in a form to default to
23:59 if a date is entered in the Date Field. And to leave the Time blank if
there is no date. What would be the formula or expression for this and where
should I place it in the form?

Fields:
Date
Time

Please help! Thank you!
 
personally, I wouldn't have a time field I would have a date/time field that
contains both values. Then, on my form, I would hide the bound textbox that
is associated with this field. Then, in the forms current event I would use
the DateValue and TimeValue functions to fill in the unbound controls
(txt_Date and txt_Time) based on the value in the bound field. Finally, in
the afterupdate event of these two unbound textboxes, I'd write code that
concatenates the two values and updates the bound field.

If you really want to default the time to #23:59# if no time value is
entered, enter that as the default value of the unbound textbox for new
records, or use the forms BeforeUpdate event to add #23:59# to the bound date
field if the unbound time box is empty.
 
Kaylen,

In addition to what Dale said...

If your fields are, in fact, named Date and Time then you will eventually
have a problem because Access will have a problem, especially Access 2007.
You should change the name of those fields. To get a complete list of
Access Bad Words see...

http://allenbrowne.com/AppIssueBadWord.html

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
Back
Top