Format Current Date

  • Thread starter Thread starter Meryl
  • Start date Start 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!
 
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!
 
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.
 
Back
Top