Solved

How to limt new records added to an Access 2013 table?

Posted on 2014-09-06
2
150 Views
Last Modified: 2014-11-28
How can I create an Access form which will only allow the user to enter just one record into a table.  This form will be emailed to a client, and will need this feature in order to avoid duplication.  Thanks
0
Comment
Question by:eq2006
2 Comments
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 40307544
Do you mean the TABLE will hold only one record, or do you mean the Table will hold multiple records, but you want your client to one enter one?

If the first, then just check the record count of the table before you allow the form to update:

Sub Form_BeforeUpdate(Cancel as Integer)
  If Me.NewRecord Then
    If DCount("SomeField", "YourTableName") >0 Then
      MsgBox "You cannot add more records"
      Cancel = True
    End If
  End If
End Sub

If the second, then the best way to prevent duplication is to add a Unique Index to the table, and include the Fields that would define a duplicate record. For example, in a Customer table, I might consider the CustomerName, CustomerZip and CustomerPhone to be unique. If so, then I'd create an Index on the table, and include all three of those fields, and set the Unique property to True.
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 250 total points
ID: 40308714
Have a field of data type Long Integer with a default value of 0 (zero) and set this as the Primary Key.
Don't show the field on the form.
The client may create, update, or delete this single record but cannot add another record.

/gustav
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question