Time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please correct my statement so it works. Trying to set a timer on a form to
evaluate the time to see if the Database needs to be logged off. Thanks!!

Public Function Time()


If Time > #12:00:00 PM# Then
DoCmd.RunMacro "Down", , ""

Else
' Not the time


End If

End Function
 
You are calling your own function Time and within it calling the built in
Time function, so you'll need to change your function's name to something
like GetTime. It could even be possible that its acting recursively as
currently named, and as your function will always return Null the expression
Time > #12:00:00 PM# will always evaluate to Null.

Ken Sheridan
Stafford, England
 
Hi Ken,

Tried this and attached it to a Button on a form...still didnt work. Love
Access but VB isnt my cup of tea. Maybe I am approaching it wrong? Please
review. Thanks again...you have helped me many times!!! Tony

Private Sub Command0_Click()

If Time > #3:54:00 PM# Then
DoCmd.RunMacro "Down", , ""

Else
' Not the time


End If

End Sub
 
The time is now 5:15:00 PM and it still doesnt work. Thought I had it but I
dont. Any help?

Thanks

Private Sub Command0_Click()

If Time > #5:14:00 PM# Then
DoCmd.RunMacro "Down", , ""

Else
' Not the time


End If

End Sub
 
In what way isn't it working? The expression Time > #5:14:00 PM# is fine.
Its currently returning False where I am as its turned midnight here. What
does the 'Down' macro do?

Incidentally you can just omit the last two arguments of the RunMacro method
as they are optional:

DoCmd.RunMacro "Down"

Ken Sheridan
Stafford, England
 
Not strictly true as the OP could disambiguate the VBA Time function as in

If VBA.Time ...

to test this just try

Function Time()
Time = VBA.Time
End Function

and then
?Time in the debug window

but I wouldn't recomend it.
 
<picky>

A better test to show that it works might be:

Function Time()
Time = DateAdd("h", 5, VBA.Time)
End Function

or

Function Time()
Time = "It's currently " & VBA.Time
End Function

</picky>
 
Not sure why but when I changed it to Time >= it worked fine, but did not
work with just > Anyhow, problem solved....Thanks
 
Really that's <double picky> as I was being icky in the first place <g>.

Just to be <triple picky> :^}.
 

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

Back
Top