time and date control

  • Thread starter Thread starter bryce
  • Start date Start date
B

bryce

I want a control on a form to display current date/time
when the control takes focus or is clicked on. Sounds
like a simple thing to do right? I a have tried to use
the "=now()"expression in the event properties but it
doesn't work. What is the easiest way to do this? I have
absolutley no VB skills.

TIA
bryce
 
Hi Bryce

Set the control source in the property sheet for the field
you want with a value of '=now()' go to the on click
property and set a macro to do a Requery making sure you
have entered the control's name at the bottom of the
screen. Once you have saved everything put the form back
into runtime mode and you will find that the date will
update every time you click it.

Cheers
John
 
Hi Bryce,

you can use both the controls Click event and the GotFocus
event to do this. View the properties for the control and
click the builde button for the relevant property and
select 'code builder'. Make each even read as follows
(the event name will correspond to your control name):

Private Sub Text0_Click()
Text0.Text = Now()
End Sub

Private Sub Text0_GotFocus()
Text0.Text = Now()
End Sub

hth

chas
 
John,
thanks for the tip. Seems to work but..... I want the
control source to be a field that gets updated with the
current date time when selected (not just to display).
This control is part of a form for a user to enter in a
date/time that a task was completed. I want the current
date/time to display as default when the user tabs to this
control. Then allow then to change the date/time if
nessesary. Make sense? Any thoughs?
 
Back
Top