MS-Access / Getting Started

Number of Records

A nice approach for reducing functionality in a database application is to simply limit the number of records. After all, what good is a database where you can store only a few records? There are two ways to do this, one of which requires code and one that doesn't. The method that requires code is to use the BeforeUpdate event of a bound form. In this case, cancel the event when you exceed your pre-set maximum number of records, as shown in the following code:

' max number of records
Private Const MAX_RECORDS As Long = 10
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim n As Integer
    n = Nz(DCount("*", "tblAssets"), 0)
    If (n + 1 > MAX_RECORDS) Then
	Cancel = True
	MsgBox "Cannot add additional records in this edition of the database.", _
	    vbExclamation, "TRIAL VERSION"
    End If
End Sub

The second technique is to use the validation rule property of an AutoNumber field in a particular table. For example, say that you have a field in a table called ID, which is an AutoNumber. Set the validation rule property of this table to <= 10 to prevent adding more than 10 records to the table.

This last technique is not bulletproof. The AutoNumber value is incremented on first edit, so if you begin inserting a record but undo the commit, the AutoNumber seed is still incremented. As a result, users may not be able to store 10 records in the table.

Limited Functionality

One of the easier ways to limit the use of an application is to simply not ship all of it. This can be challenging to do if there are dependencies between features of your application. You might also consider leaving user interface entry points to the missing features as advertisement for the full version.

[Previous] [Contents] [Next]