Far too logical - TIME()

  • Thread starter Thread starter Stan Smith
  • Start date Start date
S

Stan Smith

I have text boxes (Call_start) and (Call_End) where operators can input the
time in hh:mm when the call starts and ends.
I would like to "automate" this to a degree such that when the operator
clicks on the box the time is automatically entered.
So in the properties box under "On Click" I entered = time(). However when I
click on the box nothing happens????
Where am I going wrong???
Stan
 
I think the control you are looking for is =Now() and not time()

Hope it helps
Rudi Groenewald
 
When you enter a function name as the event property like that, the return
value of the function is disgarded. You need to use a VBA event procedure to
assign the return value to the Value property of the text box ...

Private Sub Text0_Click()

Me!Text0 = Time()

End Sub

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Stan Smith said:
I have text boxes (Call_start) and (Call_End) where operators can
input the time in hh:mm when the call starts and ends.
I would like to "automate" this to a degree such that when the
operator clicks on the box the time is automatically entered.
So in the properties box under "On Click" I entered = time(). However
when I click on the box nothing happens????
Where am I going wrong???
Stan

Having "=Time()" as an event property doesn't actually do anything to
assign the time value to the control. Rudi Groenewald is probably
right, also, in sayting that you're going to want to use Now(), which
returns the date *and* time, instead of just Time(). However, you're
going to have to write a little code to actually get the value of Now()
and assign it to the text box. You would set the On Click event
property of each text box to "[Event Procedure]", and then add these
event procedures to the form's code module:

'----- start of code -----
Private Sub Call_Start_Click()
Me!Call_Start = Now()
End Sub

Private Sub Call_End_Click()
Me!Call_End = Now()
End Sub
'----- end of code -----

That should do it.
 
Hi Rudi,

Now() is date and time
Date() is date only
Time() is time only

All he really asked for is time, but I think date and time would be a better
choice because he can calculate difference that are greater than 24 hours.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Thanks folks, got it going with Dirk's suggestion and using the "Short Time"
format to only display the HH:mm.
Did try Brendan's " Me!Call_start = Time()" which produced a compile error -
"Expected variable or procedure not module".
However operators ecstatic and I'm learning.
Cheers
Stan


Dirk Goldgar said:
Stan Smith said:
I have text boxes (Call_start) and (Call_End) where operators can
input the time in hh:mm when the call starts and ends.
I would like to "automate" this to a degree such that when the
operator clicks on the box the time is automatically entered.
So in the properties box under "On Click" I entered = time(). However
when I click on the box nothing happens????
Where am I going wrong???
Stan

Having "=Time()" as an event property doesn't actually do anything to
assign the time value to the control. Rudi Groenewald is probably
right, also, in sayting that you're going to want to use Now(), which
returns the date *and* time, instead of just Time(). However, you're
going to have to write a little code to actually get the value of Now()
and assign it to the text box. You would set the On Click event
property of each text box to "[Event Procedure]", and then add these
event procedures to the form's code module:

'----- start of code -----
Private Sub Call_Start_Click()
Me!Call_Start = Now()
End Sub

Private Sub Call_End_Click()
Me!Call_End = Now()
End Sub
'----- end of code -----

That should do it.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top