Return the current date in a field on a form

C

Chris

Can anyone help? I have this simple code to return the current date in a
field on a form in the On Load event:

Text73 = Date

Text73 is the name of the field, but the value it returns is: 12/30/1899?
How do I get today's current date? Thanks.
 
J

John Spencer

As a guess you have a field or function named date in your database.
This can cause confusion when you want Access to use the date function.

You can try the following as a temporary solution. But you should track
down where the problem is coming from.
Me.Text73 = DateValue(Now())

Now() returns the current date and TIME. DateValue will strip off the
time and return just the date.
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
M

MStest

John said:
As a guess you have a field or function named date in your database.
This can cause confusion when you want Access to use the date function.

You can try the following as a temporary solution. But you should track
down where the problem is coming from.
Me.Text73 = DateValue(Now())

Now() returns the current date and TIME. DateValue will strip off the
time and return just the date.
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
K

Ken Sheridan

You can also avoid ambiguity by qualifying the function name with an
explicit reference to VBA:

Text73 = VBA.Date

But do take note of John's advice to track down and correct the source
of the ambiguity. Naming an object 'Date' is not a good idea.

Ken Sheridan
Stafford, England
 

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