Solved

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

Posted on 2014-09-06
2
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 50

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

696 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