Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Date" Field vs. Date() Function 1

Status
Not open for further replies.

BTilson

Programmer
Jul 14, 2004
139
US
I have a table with a field in it called "date" that, obviously enough, stores the date that the current record was created. I have a form based on a query that uses this table. The query uses a text box on the form as criteria, and it works perfectly fine if I manually type in a date and then click the button. However, I was trying to make the default value of that text box be the current date via the date() function.

However, when I try to do this with the text box properties OR directly through code it gives me an error. I'm not positive, but I THINK this error is being generated because Access doesn't know how to differentiate between the date field in my table and the date() function.

Is there any way around this, without having to rename the field in my table? I don't want to have to do this, because this database file has a very large amount of queries and reports that are based on this table.

So does anyone have any other suggestions?

Thanks a ton.

Brooks Tilson
Database Development
Tilson Machine, Inc.
 
Brooks,

Date is a reserved word in Access. I'd give it
another name. Otherwise, you will have more trouble
with it down the road.

Wayne
 
The usual (most appropriate?) way, is to avoid reserwed words when naming your fields, controls, forms, variables...

However, you'll usually circumvent most inconveniences thru surrounding any references with [brackets], as one also does, when using spaces and specialcharacters in object names.

Also, I think using the syntax:

[tt]me("date").value
rs("date").value[/tt]

may help, but I don't know for sure, cause I avoid reserwed words when naming;-)

Roy-Vidar
 
Have you tried this ?
=VBA.Date()

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks a ton. That worked instantly.

Brooks Tilson
Database Development
Tilson Machine, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top