Reputation: 743
I have a form with two buttons on it that opens a form. One button is for adding new records only. The other button is for editing existing records only. The editing existing button opens the form and displays only the filtered records, however when I get to the last record I can advance to a new record using the record selector. Is there a way to prevent the user from adding new records when the form is opened via selecting the editing existing button?
BTW, the unique ID is an Autonumber field (UID) if that is useful.
The code for the latter button is as follows:
Private Sub cmdEditProjects_Click()
Dim strSQL As String
DoCmd.OpenForm "New Data", , , , acFormEdit
strSQL = "SELECT Table1.Car, Table1.Color, Table1.Owner, Table1.PurDate, Table1.ID, Table1.Pending FROM Table1 WHERE (((Table1.Pending)=-1) AND ((Table1.InActive)=0));"
Forms![New Data].RecordSource = strSQL
End Sub
Upvotes: 0
Views: 6136
Reputation: 97131
After you open the form, you can set its AllowAdditions
property to False.
DoCmd.OpenForm "New Data", DataMode:=acFormEdit
Forms![New Data].AllowAdditions = False
Upvotes: 2