Fred: the Date function that you suggested that I use is returning the value
of the 'EntryDate' that I am using elsewhere in the form (the date the record
was created). When I use the Now function, it returns the current date and
time. This is what I need however, I do not want the time part of the Now
function to be included. Can you suggest how I can use the Now function
with a Medium Date format without displaying the time information?
:
On Sun, 29 Jan 2006 09:22:52 -0800, Ernie Sersen wrote:
I have a form with a 'Received' check box. When the checkbox is checked, I
want the Date_Received field to populate with today's date. I hope this
popluates the Date_received field in the table as well. When the box is
unchecked, I want the date to disappear from the form and the table. I also
need to be able to over-ride this date manually from time to time.
Thanks.
Ernie Sersen
1) Add a Date_Received field to your table, Date/Time datatype.
2) If a Query is the Form's record source, then add the
[Date_Received] field to the query.
3) Add the [Date_Received] field to your form by dragging it from the
Field List tool button.
4) Code the [Received] check box AfterUpdate event:
If Me![Received] = -1 then
Me![Date_Received] = Date
Else
Me![Date_Received] = Null
End If
Date() returns the just current date.
Now() returns the current date and time.
In VBA, it is not necessary to include the parenthesis when using
Date, i.e. Date = Date() . Indeed if you include the parenthesis, the
Code editor will strip them off.
Both are stored as a Double number. The Integer portion represents the
number of days since 12/30/1899. The Decimal portion is the part of
the day since midnight.
Either way, you can display just the date value by setting the
control's Format property to mm/dd/yyyy.
By the way, the code I gave you should be entering the current date in
the [Date_Received] field. I suspect either you miss-wrote the code,
placed it in the wrong event, or you have something else going on
which you did not mention.