Solved

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

Posted on 2014-09-06
2
151 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

861 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