By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 2,334 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

Date() in a form module

P: n/a
Just a general question to satisfy my natural curiosity. I have noticed
that when I type Date() as part of a procedure behind a form, the ()
brackets drop off the end of it immediately I type them. It does, however
appear to work as though they were there.

Does this mean that I shouldn't use Date as a field name in a procedure as
today's date - Date() ends up as Date after the brackets disappear?

dixie
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Date is a reserved word. In VBA it stands for the system date. You can both
read and assign its value.

There is also a Date() function that you can use in other contexts, such as
in the ControlSource of a text box in in the Criteria of a query. As you
found, if you use the Date() function in a module, VBA replaces it with the
Date statement.

It is important to avoid using reserved words such as Date as field names.
If you do, your code is likely to be ambiguous, so the results may be
different from what you intend. Always use another name, such as OrderDate.

Also avoid using the names of built-in properties. For example, almost
everything in Access has a Name property, so if you create a field called
"Name" Access is likely to misunderstand the reference because Me.Name is
the name of the form. The same happens with Section (because forms have a
Section), etc.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"dixie" <di****@dogmail.com> wrote in message
news:s3***************@nnrp1.ozemail.com.au...
Just a general question to satisfy my natural curiosity. I have noticed
that when I type Date() as part of a procedure behind a form, the ()
brackets drop off the end of it immediately I type them. It does, however
appear to work as though they were there.

Does this mean that I shouldn't use Date as a field name in a procedure as
today's date - Date() ends up as Date after the brackets disappear?

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.