Re: problem getting a value from Date()
- From: "Stuart McCall" <smccall@xxxxxxxxxxxxxxx>
- Date: Sun, 4 May 2008 12:38:52 +0100
"Paul" <begone@xxxxxxxx> wrote in message
news:uCzSDdZrIHA.2520@xxxxxxxxxxxxxxxxxxxxxxx
Thanks for replying to my message, Arvin, but in fact the code doesn't
work.
I didn't mean to suggest that I tried using MsgBox Date() in the Immediate
Window. I only used ?Date() in the Immediate Window, and it does work.
I tried using
MsgBox Date
in the VBA procedure in an effort to debug the problem, but it produces
the error "Invalid Outside Procedure."
I get the same error "Invalid Outside Procedure"when I try to use
Me!txtDate = Date()
in the code as well.
Can anyone tell me why I'm getting this error message when I try to use
the Date function in this procedure?
Thanks
Paul
"Arvin Meyer [MVP]" <a@xxxxx> wrote in message
news:O0wuySZrIHA.1316@xxxxxxxxxxxxxxxxxxxxxxx
Your code should work. Your MsgBox example should be:
? MsgBox(Date())
or
? MsgBox(Date)
You can't use a msgbox as a statement in the Immediate Window, you need
to use the function.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
"Paul" <begone@xxxxxxxx> wrote in message
news:%23oZnB%23YrIHA.1772@xxxxxxxxxxxxxxxxxxxxxxx
I'm trying to write a line of code that will update a date field
(txtDate) in a form to the current date whenever a value in another
field is changed. To that end, I've tried using the following:
Private Sub Activity_AfterUpdate()
Me!txtDate = Date()
End Sub
but it doesn't do anything. That is, it doesn't enter today's date in
txtDate.
I've also noticed that in the Immediate pane, ?Date() produces the
current Date, but MsgBox Date() produces an error becuase Date() is
null.
Why does VBA recognize Date() in the immediate pane as having a value of
today's date, while the MsgBox function thinks it has no value? And
what can I do to reset txtDate to today's date whenever the value in the
Activity field is updated?
Thanks in advance,
Paul
To you it may seem that your debugging code is inside a procedure, bit it
isn't. Check that all your Sub and Function procedures are correctly
declared and terminated, ie:
Sub Something()
'Code
End Sub
Function SomethingElse()
'Code
End Function
Also look for 'orphaned' terminators, like an End Sub line with no
corresponding Sub Something() line above it.
.
- Follow-Ups:
- Re: problem getting a value from Date()
- From: Paul
- Re: problem getting a value from Date()
- References:
- problem getting a value from Date()
- From: Paul
- Re: problem getting a value from Date()
- From: Arvin Meyer [MVP]
- Re: problem getting a value from Date()
- From: Paul
- problem getting a value from Date()
- Prev by Date: Re: Updating Listbox
- Next by Date: Re: %userprofile% - Syntax
- Previous by thread: Re: problem getting a value from Date()
- Next by thread: Re: problem getting a value from Date()
- Index(es):
Relevant Pages
|