constraint

  • Thread starter Thread starter DL
  • Start date Start date
D

DL

Hi,
I have a time registration database where employees can fill in the time
they have worked on a project.
They can write down their time round on half hours.
So they can fill in :
01:00 or 01:30 or 06:30
but not!
01:15 or 06:45 or 03:05

p.s. The minimum time also has to be at least 30 min. ( -> 00:30 )

Can anybody help me with this constraint (macro or VB)?


Thank you very much!!
 
One crude approach would be something along the lines of the following
untested aircode:

Private Sub txtLogTime_BeforeUpdate(Cancel As Integer)

Dim strHours As String

strHours = Right(Format(CDate(Me.txtLogTime), "hh:nn"), 2)
Cancel = (Left$(strHours, 1) <> 0 And Left$(strHours, 1) <> 3) Or
Right$(strHours, 1) <> 0
If Cancel = True Then
MsgBox "Uhuh"
End If

End Sub
 
Back
Top