ACC1x: Preventing Users from Adding New Records |
Q100465
The DefaultEditing form property, when set to AllowEdits, allows users to both modify existing records and to add new records. Microsoft Access has no built-in mechanism to prevent users from adding new records.
The following example demonstrates a sample, user-defined Access Basic
function that you can use to prevent users from entering new employees in
the Employees form in the sample database NWIND.MDB:
Function PreventNew ()
Dim X
On Error Resume Next
X = Screen.ActiveForm.Bookmark
If Err = 3021 Then DoCmd GoToRecord , , A_LAST
End Function
NOTE: There are two commas between GoToRecord and A_LAST above.
Form: Employees
----------------------------
OnCurrent: =PreventNew()
Function RecordsExist (TableQueryName As String)
Dim DB As Database
Dim DS As Dynaset
Set DB = CurrentDB()
On Error Resume Next
Set DS = DB.CreateDynaset(TableQueryName)
DS.MoveFirst
If Err <> 0 Then
RecordsExist = False
Else
RecordsExist = True
End If
End Function
Keywords : kbprg
Issue type : kbinfo
Technology :
|
Last Reviewed: November 4, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |