Checkbox to get today's date

G

Guest

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
 
F

fredg

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
 
G

Guest

Thanks! I'll give it a try.

fredg said:
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
 
G

Guest

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?

fredg said:
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
 
F

fredg

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?

fredg said:
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.
 
F

fredg

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?

fredg said:
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.

I'm sorry.
You wanted a medium date format.
Set the control's Format property to "Medium Date" or write:
dd-mmm-yyyy
in the format property.
 
G

Guest

Curious discovery. What you said worked however... I had to move the 'Entry
Date' field in my table BELOW the 'Date_Received' field in the Table Design
view otherwise when I checked the 'Received' box, it input the 'Entry Date'
into the 'Date_Received' field. With the fields moved per the above, I get
today's date when I check the box.



fredg said:
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.

I'm sorry.
You wanted a medium date format.
Set the control's Format property to "Medium Date" or write:
dd-mmm-yyyy
in the format property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top