Capturing CurrentTime

  • Thread starter Thread starter Vrijesh
  • Start date Start date
V

Vrijesh

Hi All,

I am new with VBA for acces and am trying to capture the
system time on the click of a button. Could someone tell
me how to do it? I've created an click event for the
button which should capture the current system time and
display it in a text for on the form. Everytime I try it I
get an error "Control must have focus to reference its
property or method"

This is the code I use:

Private Sub Command28_Click()
Text24.Text = FormatDateTime(Now, vbLongTime)
End Sub

Thanx in advance..
 
Unlike VB, in Access VBA you set the Value of a control:
Private Sub Command28_Click()
Me.Text24.Value = Now()
End Sub

The Text property applies only to what the user is typing into a control
before it is validated and becomes the value. For example, while the user is
typing in a date, a text box might have this as its Text property:
1/1/
but that could never become its Value as it is not complete yet.

Value is the default property, so you can also use:
Me.Text24 = Now()

If you wisht to see the time only, set the Format property of the text box
to:
Long Time
 
Back
Top