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


D

Dirty70Bird

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.
 
Ad

Advertisements

J

John W. Vinson

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.
 
J

John W. Vinson

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.
 
Ad

Advertisements

D

Dirty70Bird

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"...
 

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