No Duplicates

A

Andrew C

My company i work for runs a market day once a month. People have to ring up
and register with the business and then they are registered for the market
day.

They can then attend future market days by ringing us up and confirming they
want to attend.

Each market day has its own identifying number and each member has their own
member number. And these are recorded in a table. what i need to stop is a
person ringing up and registering twice for the same market day.

So in the table the a client number cant appear with the same market number.

Fields in the table are as listed.

Table = PPAtend
Client No = Clients
Market Number = PPDates

Information is enter by a form (PP Date) which which lists all market dates
and then there is a subform (Market) which lists the people attending each
market day.

Can someone help me with the little problem. Thanks in advance

Andrew
 
L

Linq Adams via AccessMonster.com

Go into Table design and make your two fields a Composite Primary Key. IF you
try to enter a duplicate PK, Access will throw error 3022.

Go into the code window for you form and enter this code:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim Message As String
If DataErr = 3022 Then 'Duplicate date/company combination
Message = "You are trying to enter a date/company combination that already
exits!"
Response = MsgBox(Message, vbExclamation, "Attempting Dupicate Entry!")
Response = acDataErrContinue
Me.Undo
End If
End Sub

Now, if you enter a duplicate company/dtae combination Access will throw
error 3022, and instead of the usual nasty Access error message, a message
box with a custom error message will appear, and the new record will be
dumped.
 
G

Gary McCarthy

The system error I receive when my Load ID field is a duplicate does not give
an error number. How can I know the error number to include in the error
handling?

Thanks.
 

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