Dont know if this is any help.
It was used to input race finishing times where the previous time was the
base line and if you keyed in a 1 or 2 digit number it assumed the base time
+ the number of seconds keyed in. If you keyed in a 4 digit number int
interpreted it as minutes and seconds. Might be the basis of your code.
Sorry about the race crap in it
Phil
Private Sub EnterTime_AfterUpdate()
Dim TimeStg As String
Dim Time As Date
Dim Secs As Integer, Mins As Integer, Hours As Integer
Dim NewSecs As Integer, NewMins As Integer
If Nz(EnterTime) = 0 Then
DoCmd.GoToControl "RaceFinishTime"
End If
If Nz(LastTime) = 0 Then
DoCmd.GoToControl "RaceFinishTime"
Exit Sub
End If
TimeStg = CStr(LastTime)
If Not IsNumeric(EnterTime) Then
DoCmd.GoToControl "RaceFinishTime"
Exit Sub
End If
Seconds:
Secs = Right$(LastTime, 2)
Mins = Mid$(LastTime, 4, 2)
Hours = Left(LastTime, 2)
If Len(EnterTime) <> 2 Then ' 2 figures for seconds
GoTo SecsWithPoint
End If
If EnterTime < 0 Or EnterTime > 59 Then
MsgBox "There are 60 seconds in a minute", vbCritical
Exit Sub
End If
If EnterTime < Right$(TimeStg, 2) Then ' next minute
Mins = Mins + 1
If Mins > 59 Then
Hours = Hours + 1
Mins = 0
End If
End If
TimeStg = Hours & ":" & Mins & ":" & EnterTime
GoTo Update
SecsWithPoint:
If Len(EnterTime) <> 3 Then
GoTo Minutes
End If
If Left$(EnterTime, 1) = "." Or Left$(EnterTime, 1) = ":" Then
EnterTime = Right$(EnterTime, 2)
GoTo Seconds
End If
Minutes:
If Len(EnterTime) <> 4 Then ' Not minutes
DoCmd.GoToControl "RaceFinishTime"
End If
NewSecs = Right$(EnterTime, 2)
NewMins = Left$(EnterTime, 2)
If NewSecs < 0 Or NewSecs > 59 Then
MsgBox "There are 60 seconds in a minute", vbCritical
Exit Sub
End If
If NewMins < 0 Or NewMins > 59 Then
MsgBox "There are 60 minutes in an hour ", vbCritical
Exit Sub
End If
TimeStg = Hours & ":" & NewMins & ":" & NewSecs
Update:
Time = CDate(TimeStg)
RaceFinishTime = Time
LastTime = Time
If IsNull(RaceFinishTime) Then
RaceFinishDate = Null
Exit Sub
End If
LastTime = RaceFinishTime
If IsNull(RaceFinishDate) Then
If RaceFinishTime < GetStartDate(DivisionID, 2) Then ' At least
next day
RaceFinishDate = DateAdd("d", 1, GetStartDate(DivisionID, 2)) '
Next day
Else
RaceFinishDate = GetStartDate(DivisionID, 1) '
same day
End If
End If
CorrectedTime.Requery
End Sub
Private Sub EnterTime_BeforeUpdate(Cancel As Integer)
Dim Msg As String
Dim StartDate As Date, StartTime As Date
StartTime = GetStartDate(DivisionID, 2) ' Time
If StartTime = 0 Then ' Invalid
Msg = "There is no start time set for: " & Division
MsgBox Msg, vbCritical
DoCmd.CancelEvent
Exit Sub
End If
StartDate = GetStartDate(DivisionID, 1) ' date
If StartDate = 0 Then ' Invalid
Msg = "There is no start date set for: " & Division
MsgBox Msg, vbCritical
DoCmd.CancelEvent
Exit Sub
End If
If AtStartLine = True And RaceFinishTime >= StartTime And RaceFinishDate
= StartDate Then
Exit Sub
End If
If AtStartLine = False Then
Msg = "This boat has not come to the Start Line" & Chr$(13)
Msg = Msg & "Is this boat a starter?"
If MsgBox(Msg, vbInformation + vbYesNo) = vbYes Then
AtStartLine = True
Else
DoCmd.CancelEvent
Exit Sub
End If
End If
If RaceFinishTime < StartDate And RaceFinishDate <= StartTime Then
MsgBox "This boat has finished before she has started",
vbInformation
DoCmd.CancelEvent
Exit Sub
End If
If RaceFinishDate < StartDate Then
MsgBox "This boat has finished on a day before she has started",
vbInformation
DoCmd.CancelEvent
Exit Sub
End If
End Sub
"Kenny G" <kg****@hotmail.com> wrote in message
news:81**************************@posting.google.c om... Currently I have four datetime fields:
DteTimeNotified
DteTimeStarted
DteTimeCompleted
DteTimeReported
Each of these fields contain the input mask 99/99/00" "00:00;0
This gives me a short date and military time.
In order to save data entry time I would like to have each of these
fields populated whenever the entry of DteTimeNotified is complete.
ie The last three fields will be populated with the previous datetime
plus ten minutes. The cursor would need only have to go to the hours
and minutes 00:00 area of the mask for update because normally it
takes about a half hour to an hour to complete the cycle.
Any help would be greatly appreciated.
Kenny G