A (hopefully) easy one for an MVP

S

scubadiver

On a continuous subform I have a button attached to each record. In the
"click" event code I have a line which changes a check box from false to true.

What I would also like is to change a date field from being empty to being
today's date. I have tried

me.Cont_DateInv.value = date()

but the brackets disappear.

Cheers!
 
B

BruceM

I'm not an MVP, but I can say accurately it doesn't matter that the brackets
disappear. They do that in VBA when the function contains no arguments. Is
today's date being inserted into Cont_DateInv? If so, there is no problem.
If not, it is not because of the parentheses. BTW, Value is the default
property, so you can save youself the bother of specifying it (although it
does no harm as far as I know).
 
P

pietlinden

On a continuous subform I have a button attached to each record. In the
"click" event code I have a line which changes a check box from false to true.

What I would also like is to change a date field from being empty to being
today's date. I have tried

me.Cont_DateInv.value = date()

but the brackets disappear.

Cheers!

why not just add the code to the checkbox's AfterUpdate event? No MVP
required...
me.Cont_DateInv=Date()

..Value is the default. You don't really need to state it explicitly
 
R

Ron2006

That is the way it is designed to work.

If you notice, when you put in
me.Cont_DateInv.value = date()

it changes to
me.Cont_DateInv.value = Date


which is saying that Access is recognizing your use of the reserved
word/function "Date" which does not require a set of parens. ().....

There are other places, for instance in the query builder wizard ( I
believe) where the parens are NOT delected and are required for the
function to be properly used.

General rule: Put them in as you write the code and if Access takes
them out, then most probably they are not required.


Ron
 
A

Arvin Meyer [MVP]

Date() is a function which returns the current date.

Date is a VBA constant which IS the current date.

That is why you must use Date() in a query or expression, and Date in VBA
code.
 
S

scubadiver

The checkbox isn't being used in the forms but it has worked in the "click"
event.
 
B

BruceM

Access 2003 Help is a bit unclear on these points. It lists Date in VBA
Help as "Date Function(VBA)", where it is described thus: "Returns a
variant (Date) containing the current system date". For "Date constant" it
lists such things as vbSunday, and says they are used with the
firstdayofweek argument, but it provides no further information about that
argument or where it is used. Upon further digging, these constants are
used with the Weekday function.
I like your explanation better.
 
T

Tony Toews [MVP]

And notice that you received lots of very helpful answers from non
MVPs. So please just ask your question in the future.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Top