auto default dependent on text

  • Thread starter Thread starter Clan McCreery
  • Start date Start date
C

Clan McCreery

Hello,

I have a time clock program where [txtTime] is the
employee's scheduled time to start work, and
[txtClockTime] is the actual time they "punch in"...they
click a button [butCurrentTime] which enters the
computer's time into the text box.

If an employee clocks in early, I want the time to default
to the time in [txtTime], if they are on time or late, I
want the actual time. So I wrote code on the "on click"
command of [butCurrentTime] which says:

If Time() is < [txtTime] then
[txtClockTime] = [txtTime] else
....(code for inserting time)

When I click butCurrentTime I only get the current time,
it doesn't read my if then else...can someone please help
me with this? Its the last component of a project I
really want to wrap up!!
Thanks!
Clan McCreery
 
Hi Clan,

I am assuming that txtTime is a text-field control on the
form and it holds a valid date/time value (otherwise you
would be comparing two different data types and your if-
statement would always be false). If txtTime is a form
control and contains valid data, why don't you try
something like this:

If Now < Me.txtTime.Value Then
Me.txtClockTime.Value = Me.txtTime.Value
else
Me.txtClockTime.Value = Now
End If

Me.Recalc

Hope that helps. --Rick
 
Back
Top