constraint

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!!
 
D

Douglas J. Steele

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top