Default date field

  • Thread starter Thread starter Amelia
  • Start date Start date
A

Amelia

Hi, I have a date field and I have to default to now(). Is there a way to
only have it go to the default date only if no date has been entered?

So for example if date=null, now(). I did not try a command because I am not
sure what the code would be.

Thanks!
 
No, it really isn't working correctly. You have a field named date. Date is
an Access reserved word and can cause problems. I have personally seen a
situation where even putting the name in brackets [date] would not resolve
the problem. It is important you change the name to something else.

The Date function is like the Now function without the time portion.
A simple way to do this is: SomeDate =Nz(SomeDate, Date)
 
Thanks, but the field is not just [date] it is actually called [invoice date]
I have the default as now() in the properties and it does let me go in and
change the default. Must of just had a bad moment that it didn't let me
update!

Thanks though.

Klatuu said:
No, it really isn't working correctly. You have a field named date. Date is
an Access reserved word and can cause problems. I have personally seen a
situation where even putting the name in brackets [date] would not resolve
the problem. It is important you change the name to something else.

The Date function is like the Now function without the time portion.
A simple way to do this is: SomeDate =Nz(SomeDate, Date)

--
Dave Hargis, Microsoft Access MVP


Amelia said:
Never mind it is working correctly now.
 
Do you really need the time value in the field? It can cause problems when
filtering because the comparison will include the time. If you try something
like this with time in the field
:
WHERE [Invoice Date] Between #7/1/2009# AND #7/31/2009#

You will miss most or all of the records for 7/31/2009. That is because the
full value it will use will be 07/31/2009 12:00:00 AM.

If a field contains 07/31/2008 12:00:01 AM or any time after 1 minute after
midnight, that record will be excluded.
--
Dave Hargis, Microsoft Access MVP


Amelia said:
Thanks, but the field is not just [date] it is actually called [invoice date]
I have the default as now() in the properties and it does let me go in and
change the default. Must of just had a bad moment that it didn't let me
update!

Thanks though.

Klatuu said:
No, it really isn't working correctly. You have a field named date. Date is
an Access reserved word and can cause problems. I have personally seen a
situation where even putting the name in brackets [date] would not resolve
the problem. It is important you change the name to something else.

The Date function is like the Now function without the time portion.
A simple way to do this is: SomeDate =Nz(SomeDate, Date)

--
Dave Hargis, Microsoft Access MVP


Amelia said:
Never mind it is working correctly now.

:

Hi, I have a date field and I have to default to now(). Is there a way to
only have it go to the default date only if no date has been entered?

So for example if date=null, now(). I did not try a command because I am not
sure what the code would be.

Thanks!
 
Back
Top