Format Current Date

M

Meryl

I have a form that contains a completed flag field and a completed date
field. If the user checks the completed date field, I want to populate the
completed date field with the current date, allowing the user to change it if
they like.

I have been able to make that happen, however, when the user tries to change
the field they see the time in the field as well. I don't know how to format
the field so that doesn't happen.

The date field has an input mask of 99/99/00;;_ and display mask mm/dd/yy

I have the following code in the on click event for the completed flag:

If Completed_Flag = True And IsNull([Completed_Dt]) Then
Me.Completed_Dt.Value = Now()
End If

Is there a way to format the Now() date so that it only stores the date in
mm/dd/yy format?

Many thanks!
 
M

Meryl

Perfect! Date() works!! Thank you.

Dennis said:
Use Date() instead of Now() or Me.Completed_Dt.Value =
Format(Date(),"mm/dd/yy")

Meryl said:
I have a form that contains a completed flag field and a completed date
field. If the user checks the completed date field, I want to populate the
completed date field with the current date, allowing the user to change it if
they like.

I have been able to make that happen, however, when the user tries to change
the field they see the time in the field as well. I don't know how to format
the field so that doesn't happen.

The date field has an input mask of 99/99/00;;_ and display mask mm/dd/yy

I have the following code in the on click event for the completed flag:

If Completed_Flag = True And IsNull([Completed_Dt]) Then
Me.Completed_Dt.Value = Now()
End If

Is there a way to format the Now() date so that it only stores the date in
mm/dd/yy format?

Many thanks!
 
F

fredg

I have a form that contains a completed flag field and a completed date
field. If the user checks the completed date field, I want to populate the
completed date field with the current date, allowing the user to change it if
they like.

I have been able to make that happen, however, when the user tries to change
the field they see the time in the field as well. I don't know how to format
the field so that doesn't happen.

The date field has an input mask of 99/99/00;;_ and display mask mm/dd/yy

I have the following code in the on click event for the completed flag:

If Completed_Flag = True And IsNull([Completed_Dt]) Then
Me.Completed_Dt.Value = Now()
End If

Is there a way to format the Now() date so that it only stores the date in
mm/dd/yy format?

Many thanks!

That showing of the full value of a field is normal behavior when you
click in it.

Use Date instead of Now().
Now() includes a Time value. Date does not (Actually it does. It's
exactly midnight of that morning, stored as .0).
Also, as the Value property is the default control property, you do
not need to explicitly write it.

If Completed_Flag = True And IsNull([Completed_Dt]) Then
Me.Completed_Dt. = Date
End If

The actual format of the displayed date is determined by the control's
format property, and has nothing to do with how the date value is
stored.
 

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

Similar Threads

User defined date format 1
date field 4
Date problem 5
access system date format 1
Mail Merge Date Format 9
Change Color of field based on a Check box 2
Date and Time 3
date format 2

Top