Re: Time checking problem



Yes I have two fields - "TimeIn" and "TimeOut" are both Date/Time (Short
Time format)

I still get the error stating that the time in question is duplicated.
Although it hasn't.
The correct time is shown on the error displayed.

Now I also get the debug window come up with the "Method or Data not found"
and the following is highlighted (OldValue) in;

If ((Me.TimeIn = Me.TimeIn.OldValue) And


Any suggestions?

Thanks,

Neil


"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:eClfBxS6FHA.3760@xxxxxxxxxxxxxxxxxxxxxxx
> Add the line:
> Debug.Print strWhere
> just before the "varResult = " line.
> After it runs, open the Immediate Window (Ctrl+G) to see how it
interpreted
> it. Use that in the WHERE clause of a query to see what's going on. Does
the
> booking number that it reports make any sense?
>
> Does your table have 2 fields (named StartDateTime and EndDateTime in the
> example) that contain both the date and time? Are they Date/Time fields?
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
> news:%23D7UJ2Q6FHA.3648@xxxxxxxxxxxxxxxxxxxxxxx
> > Use the BeforeUpdate event of the *form* where you enter this data to
> > provide the warning if there is an overlap.
> >
> > The basic concept is that 2 events overlap if:
> > - A begins before B ends, AND
> > - B begins before A ends.
> >
> > The form's BeforeUpdate event procedure will be something like this
> > aircode:
> >
> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> > Dim strWhere As String
> > Dim varResult As Variant
> > Dim strMsg As String
> > Const strcJetDateTime = "\#mm\/dd\/yyyy hh\:nn\:ss\#"
> >
> > If ((Me.StartDateTime = Me.StartDateTime.OldValue) AND _
> > (Me.EndDateTime = Me.EndDateTime.OldValue) AND _
> > (Me.RoomID = Me.RoomID.OldValue)) OR IsNull(Me.StartDateTime) _
> > OR IsNull(Me.EndDateTime) OR IsNull(Me.RoomID) Then
> > 'do nothing
> > Else
> > strWhere = "(StartDateTime < " & Format(Me.EndDateTime,
> > strcJetDateTime) & _
> > ") AND " & Format(Me.StartDateTime, strcJetDateTime) & _
> > " < EndDateTime) AND (RoomID = " & Me.RoomID & ")
> > varResult = DLookup("BookingID", "tblBooking", strWhere)
> > If Not IsNull(varResult) Then
> > strMsg = "Clashes with booking # " & varResult & vbCrLf &
> > "Continue anyway?"
> > If MsgBox(strMsg, vbYesNo+vbDefaultButton2, "Double-booked")
<>
> > vbYes Then
> > Cancel = True
> > End If
> > End If
> > End If
> > End Sub
> >
> >
> > If you need to cope with open-ended bookings, or need to crosscheck all
> > bookings against each other, see:
> > Clashing Events/Appointments
> > at:
> > http://allenbrowne.com/appevent.html
> >
> > --
> > Allen Browne - Microsoft MVP. Perth, Western Australia.
> > Tips for Access users - http://allenbrowne.com/tips.html
> > Reply to group, rather than allenbrowne at mvps dot org.
> >
> > "Neil M" <nmansell@xxxxxxxxxxxxxxxxxx> wrote in message
> > news:dl9pnj$16r$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> >> Hi all (yet again!)
> >>
> >> I have a problem with the way my database will have the check the
> >> following.
> >>
> >> Room > Date > Time In and Time Out
> >>
> >> I want to make sure that the inputter doesn't overlap any times on the
> >> same
> >> day for the room (there are 5 rooms)
> >> So say I have booked one room on 1/1/05 for 8:00am > 9:00am, and I want
> >> to
> >> input a new record later on for the same day and room for 9:30am, I
want
> >> the
> >> program to tell me that it has already been booked for that time. It
can
> >> allow me to continue and book as at this stage I just want it to check
> >> the
> >> time for me?
> >>
> >> I would appreciate any suggestions or help as I do not really have a
> >> clue
> >> how this can be done? (my database knowledge is better than normal but
> >> not
> >> quite advanced!)
> >>
> >> Regards,
> >>
> >> Neil
> >
> >
>
>


.