By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,805 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

Date Range - avoid duplicates

P: n/a
I have an Access 2000 database, and I want the form to accept only one
entry for a person for one date range.

Example: If John (Saved in "USer" field)

books "Start Date" 01/01/07 and "End Date" 05/01/07, then he should not
be able to make any other booking that includes any of the days
between 01/01/07 & 05/01/07

How can i do this ?

Oct 12 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi, su******@gmail.com! :)

<su******@gmail.comwrote...
>I have an Access 2000 database, and I want the form to accept only one
entry for a person for one date range.

Example: If John (Saved in "USer" field)

books "Start Date" 01/01/07 and "End Date" 05/01/07, then he should not
be able to make any other booking that includes any of the days
between 01/01/07 & 05/01/07

How can i do this ?
Use the "DCount" statement. If John tries to add another booking, count, if
he already made one using

--------------Code
Dim varAlreadyBooked as Boolean
If DCount("User","YourTable","User = 'John' AND BookingDate BETWEEN
#01/01/07# AND #05/01/07#") 0 Then
AlreadyBooked = True
Else
AlreadyBooked = False
End If

If AlreadyBooked = True Then
MsgBox "Hey, where do you wanna go at this date? You already booked a
trip!",vbOkOnly + vbCritical,"Beep! Error!"
Exit Sub
End If

'If Code arrives here you can be sure that John didn't do any bookings in
the selected time period.
--------------Code

Regards

Michael
Oct 12 '06 #2

P: n/a
Michael,

Super ! Thanks, that was quick too!

Oct 12 '06 #3

P: n/a
You're welcome.

As quick as germans can get... ;-)

<su******@gmail.comschrieb im Newsbeitrag
news:11*********************@m73g2000cwd.googlegro ups.com...
Michael,

Super ! Thanks, that was quick too!

Oct 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.