Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy fields when using active clock on form

Status
Not open for further replies.

ThatNewGuy

Technical User
Jan 19, 2007
47
0
0
US
Hello,

I'm building a form with an active clock that tracks the current time via a text box. This works like a charm. It's constantly running unless the user stops the clock with a button. When the command button is selected it copies and pastes the "paused" time into another field so this data can be stored so the user can go back and still use the clock to track time after a break, interuptions, etc.

The first part of the code works fine, but I'm having problems with the second half. My objective is to take the "paused" time and transfer it to field1 then if field1 already contains data it will automatically transfer the updated time to the next available field. All in all, I plan on having four fields on the form that will be able to collect the various amounts of time spent on one project.

Any direction or help would be greatly appreciated at this point. Thanks!

--------------------------
Private Sub SaveTime_Click()
Me.TimerInterval = 0
With Me.Clock
.Visible = True
.SetFocus
DoCmd.RunCommand acCmdCopy
Me.SaveTime.SetFocus
Me.EndTime.SetFocus
DoCmd.RunCommand acCmdPaste <---code works up to this point
If Me![EndTime] <> "" Then
Me.Clock.SetFocus
Else
Me.EndTime1.SetFocus
End If
End With
End Sub


 
Why using cut'n'paste ?
What about this ?
Code:
Private Sub SaveTime_Click()
Me.TimerInterval = 0
Me!EndTime = Me!Clock
If Trim(Me!EndTime & "") <> "" Then
    Me!Clock.SetFocus
Else
    Me!EndTime1.SetFocus
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
It's not pretty but I was using cut and paste at the time bcuz it was working...haha enough said.

I tried your suggestion and it doesn't seem to change anything. Still not sending data to the second field if the first one contains data. It just overwrites the first field upon execution.

Hmmm...thank you for the suggestions though. It's much cleaner.
 
sending data to the second field if the first one contains data
Code:
Private Sub SaveTime_Click()
Me.TimerInterval = 0
If Trim(Me!EndTime & "") <> "" Then
    Me!EndTime1 = Me!Clock
Else
    Me!EndTime = Me!Clock
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV you da man! Thanks! Working great...plus it's simple and clean.
 
Well, I'm back again. Once I started building the rest of the form I ran into a problem. I now have four fields. Upon execution of the command button if field1 is empty it fills in. Then if field1 contains data it bumps the next entry to field2. The problem is when I go to enter the data in field3 it keeps overwriting the data in field2. I've tried different combo's of code and I'm not sure how to make sure the third and fourth fields remain empty until needed. The user may have to click on the command button four different times depending on any breaks, etc. thus fields 2 through 4 have to remain empty unless needed. I hope this makes sense. Below is what PHV helped with up to this point.

--------------------------
Private Sub SaveTime_Click()
Me.TimerInterval = 0
If Trim(Me!EndTime & "") <> "" Then
Me!EndTime1 = Me!Clock
Else
Me!EndTime = Me!Clock
End If
If Trim(Me!EndTime1 & "") <> "" Then
Me!EndTime1 = Me!Clock
Else
Me!EndTime2 = ""
End If
If Trim(Me!EndTime2 & "") <> "" Then
Me!EndTime2 = Me!Clock
Else
Me!EndTime2 = ""
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top