469,307 Members | 2,055 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,307 developers. It's quick & easy.

Duplicate Data

I have a form in Access which has event date and then also an event time slot such as "Morning, Afternoon, Evening" . I need to make it so that you cannot have a duplicate time booking, i assume i will need to code some VBA but if anyone could tell me what it would be much appreciated. Thanks
Apr 30 '06 #1
5 1465
CaptainD
135 100+
Look into using "Not In" in your where clause.

Select somedata from sometable where somefield NOT IN(Select DataYouDontWant)
Apr 30 '06 #2
thanks, care to elaborate? not exactly a VB expert....
Apr 30 '06 #3
CaptainD
135 100+
Not really VB or VBA but in your SQL query that will pull the information from your database. If you post how your table are layed out we can assist you with how to create the select statement to get the information you are looking for.

Using "Not In(Select statement)" is a way to filter the information you want. In your case, you don't want information that matches what you are setting up or open dates in a select time span. so in your case, it would be "Select Dates and times from YourTable where Date and time not in (select ThisDate, ThisTime)" or something along those lines.
Apr 30 '06 #4
thanks, i have two tables. THe first of which is just contact information and is named CustomerDetails, it is autoincrementing and that number is linked into the BookingDetails Table. THis contains the fields Event Date, and Event Time Slot which only allows the values of Morning, Afternoon and Evening.

The form contains a date input field and a event slot which is a drop down box, there is then a save record button to add this data to the tables.

thanks alot
Apr 30 '06 #5
cweiss
36
This may be oversimplifying it, but in your BookingDetails, why not just make EventDate and EventTime the primary key? Then they'll just get a warning if they try to add a time slot that's already taken.

Otherwise, you could use validation or SQL like CaptainD suggested. Validation would just give them a warning message if they entered a value that wasn't permissible (i.e. Time slot is taken, please select another time); or you could restrict the values they can choose from by putting a SQL statement in the Data Source property.
Apr 30 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Lowell Kirsh | last post: by
2 posts views Thread by Pablo | last post: by
2 posts views Thread by Brad Allison | last post: by
2 posts views Thread by Harry Haller | last post: by
1 post views Thread by oaklander | last post: by
4 posts views Thread by Thomas Arthur Seidel | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.