A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

dafault value for date not working with Date() but Now() is workin



 
 
Thread Tools Display Modes
  #1  
Old February 26th, 2010, 09:20 PM posted to microsoft.public.access.forms
Dirty70Bird
external usenet poster
 
Posts: 9
Default dafault value for date not working with Date() but Now() is workin

Got a table with existing data, with simple date field on a form that I want
to default to todays date. I have tried inputting the Date() into the table
default value for the date, but I get an error that says "Unknown function in
'Date' in validation expression or default value on 'Data.date'. Data is the
table name. If I enter Now() into the default value for date, it works just
fine. But, the reports that are generated, don't show the records with the
date and time in them. I can go back to the table and manually delete the
time from those records, and they then show up in the report. Any ideas? I
just want to use the default date of today in the date field.
  #2  
Old February 26th, 2010, 10:25 PM posted to microsoft.public.access.forms
bhicks11 via AccessMonster.com
external usenet poster
 
Posts: 529
Default dafault value for date not working with Date() but Now() is workin

The correct usage in Access is Now(). Date is a reserved word and really
shouldn't be used for a field name. Try changing it if possible.

Bonnie
http://www.dataplus-svc.com

Dirty70Bird wrote:
Got a table with existing data, with simple date field on a form that I want
to default to todays date. I have tried inputting the Date() into the table
default value for the date, but I get an error that says "Unknown function in
'Date' in validation expression or default value on 'Data.date'. Data is the
table name. If I enter Now() into the default value for date, it works just
fine. But, the reports that are generated, don't show the records with the
date and time in them. I can go back to the table and manually delete the
time from those records, and they then show up in the report. Any ideas? I
just want to use the default date of today in the date field.


--
Message posted via http://www.accessmonster.com

  #3  
Old February 26th, 2010, 11:54 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default dafault value for date not working with Date() but Now() is workin

On Fri, 26 Feb 2010 13:20:01 -0800, Dirty70Bird
wrote:

Got a table with existing data, with simple date field on a form that I want
to default to todays date. I have tried inputting the Date() into the table
default value for the date, but I get an error that says "Unknown function in
'Date' in validation expression or default value on 'Data.date'. Data is the
table name. If I enter Now() into the default value for date, it works just
fine. But, the reports that are generated, don't show the records with the
date and time in them. I can go back to the table and manually delete the
time from those records, and they then show up in the report. Any ideas? I
just want to use the default date of today in the date field.


Two possible issues:

first, is your fieldname Date? If so, you're getting Access confused about
whether you mean the fieldname or the builtin Date() function. Avoid using
reserved words like this as the names of fields or controls.

Second, if that's not it, you may have a bad reference. Date() seems to be
especially vulnerable to this. To see, open any module in design view, or open
the VBA editor by typing Ctrl-G. Select Tools... References from the menu. One
of the .DLL files required by Access will probably be marked MISSING. Uncheck
it, recheck it, close and open Access.

If none are MISSING, check any reference; close and open Access; then uncheck
it again. This will force Access to relink the libraries.

--

John W. Vinson [MVP]
  #4  
Old February 26th, 2010, 11:56 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default dafault value for date not working with Date() but Now() is workin

On Fri, 26 Feb 2010 22:25:19 GMT, "bhicks11 via AccessMonster.com"
u44327@uwe wrote:

The correct usage in Access is Now().



Well... not really. There is a Now() function which returns the current date
and time accurate to the second; there is *also* a Date() function which
returns the current date without a time portion (equivalent to midnight at the
start of today's date). Both functions have their uses, just depending on
whether you want the time included or not.

You're quite right about not using Date as a fieldname, though.
--

John W. Vinson [MVP]
  #5  
Old February 27th, 2010, 01:27 AM posted to microsoft.public.access.forms
bhicks11 via AccessMonster.com
external usenet poster
 
Posts: 529
Default dafault value for date not working with Date() but Now() is workin

Oh Johnny - I should have known you'd catch me!

John W. Vinson wrote:
The correct usage in Access is Now().


Well... not really. There is a Now() function which returns the current date
and time accurate to the second; there is *also* a Date() function which
returns the current date without a time portion (equivalent to midnight at the
start of today's date). Both functions have their uses, just depending on
whether you want the time included or not.

You're quite right about not using Date as a fieldname, though.


--
Message posted via http://www.accessmonster.com

  #6  
Old March 1st, 2010, 06:11 PM posted to microsoft.public.access.forms
Dirty70Bird
external usenet poster
 
Posts: 9
Default dafault value for date not working with Date() but Now() is wo

changed the field name from "date" to "dates", still same error message. I
also changed it from "date" to "chris" (my name), still same error message.

tools, references, shows "admin 1.0 type library" was missing. Unchecked,
then re-checked, closed access, re-added the date(), still same error
message. Then re-opened access, unchecked the "admin 1.0 type library" check
box, saved, then exited. Re-added the date(), now no error messages are
present. Appears to work without this "admin 1.0 type library"...

"John W. Vinson" wrote:

On Fri, 26 Feb 2010 13:20:01 -0800, Dirty70Bird
wrote:

Got a table with existing data, with simple date field on a form that I want
to default to todays date. I have tried inputting the Date() into the table
default value for the date, but I get an error that says "Unknown function in
'Date' in validation expression or default value on 'Data.date'. Data is the
table name. If I enter Now() into the default value for date, it works just
fine. But, the reports that are generated, don't show the records with the
date and time in them. I can go back to the table and manually delete the
time from those records, and they then show up in the report. Any ideas? I
just want to use the default date of today in the date field.


Two possible issues:

first, is your fieldname Date? If so, you're getting Access confused about
whether you mean the fieldname or the builtin Date() function. Avoid using
reserved words like this as the names of fields or controls.

Second, if that's not it, you may have a bad reference. Date() seems to be
especially vulnerable to this. To see, open any module in design view, or open
the VBA editor by typing Ctrl-G. Select Tools... References from the menu. One
of the .DLL files required by Access will probably be marked MISSING. Uncheck
it, recheck it, close and open Access.

If none are MISSING, check any reference; close and open Access; then uncheck
it again. This will force Access to relink the libraries.

--

John W. Vinson [MVP]
.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:40 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.