Preventing duplicate records

DazedandMuddled

is not hard? is it......?
Local time
Today, 14:23
Joined
Apr 9, 2004
Messages
11
Hi there :D

First time posting here so please be gentle!

I am creating a booking form for a private flying club.

so far i've managed to do everything except 'prevent duplicate bookings' from being stored in booking table.

how can i go about preventing bookings from being duplicated (i've included my form for you to look at)

There is an error message if the user forgets to select any of the combo boxes and another error if they select a time that overlap.

What i want to do is cut down the number of msg boxes, and essentially only one msg box appears if the info they enter is a duplicate.

sorry this is a bit of a ramble - thanks in advance!

Cam :rolleyes:
 

Attachments

DazedandMuddled said:
Hi there :D

First time posting here so please be gentle!

I am creating a booking form for a private flying club.

so far i've managed to do everything except 'prevent duplicate bookings' from being stored in booking table.

how can i go about preventing bookings from being duplicated (i've included my form for you to look at)

There is an error message if the user forgets to select any of the combo boxes and another error if they select a time that overlap.

What i want to do is cut down the number of msg boxes, and essentially only one msg box appears if the info they enter is a duplicate.

sorry this is a bit of a ramble - thanks in advance!

Cam :rolleyes:

Hi Cam,

You need to implement a composite key in your booking details table. A composite key is a primary key consisting of two fields. What uniquely identifies your records is the date and the start time. You want to make both of these fields a Primary key. The system then makes sure the combination of the two does not exist more than once.

To create a composite remove the Primary key setting from the TimesheetID field. Click the HireDate field, hold down the shift key and click the StartTime field so they are both highlighted in black. While holding down the shift key with both items selected, right click and click primary key.

This should help. It should eliminate situations where both the date and start time are duplicated.

I hope this helps :)

Cindy
 
And actually as a minor correction to cinders reply:
A composite key is a primary key consisting of two fields.

A composite key can be more than two fields. You want to use the minimum number of fields in creating your composite key that will make the identification of a row unique.
 
boblarson said:
And actually as a minor correction to cinders reply:

A composite key can be more than two fields. You want to use the minimum number of fields in creating your composite key that will make the identification of a row unique.

Absolutely...

Sorry about that, I didn't want to mislead you. I should have elaborated on composites.
 
cinders said:
It should eliminate situations where both the date and start time are duplicated.

Cinders/ Boblarson

thanks for the reply, I've added a composite key as suggested, however my command DoCmd.GoToRecord , , acNewRec no longer works.

and when i try to move to the next file i get the error message saying that i need to change data to prevent duplication.

this is exactly what i wanted to happen except i wanted it to occur after the user presses the confirm booking button.

any ideas as to how to get this portion of code to work??

But once again thanks for the swift reply. (ps my form is attached in my orignal message - in case that helps)

Cam
 
Last edited:

Users who are viewing this thread

Back
Top Bottom