Cannot Add new record, then disable AllowAdditions

  • Thread starter Thread starter Pete
  • Start date Start date
P

Pete

Re Access 2003 SP2

I'm probably going about this the wrong way, but;

I have a parent form with an 'Add Invoice' button to add a new blank invoice
line for the selected PO to the subform. Previously added Invoices for a PO
are locked.

I want to add a blank record on the subform and stop a another new record
appearing when the user begins to edit the first new (blank) record.
I have tried using:-

With subfrmInvoicesReceived.form
.SetFocus
.AllowAdditions = True
.AllowEdits = True

'add a new record for inputting
Dim rs As DAO.Recordset
Set rs = .Recordset
rs.AddNew
Set rs = Nothing
.AllowAdditions = false
End With

(used this method because I couldn't get DoCmd.GoToRecord , , acNewRec to
work at all with the subform - said the subform is not open)

The .AllowAdditions = false line throws up an error about the primary key
cannot contain a Null value. So presumable the AllowAdditions command is
trying to save the record at this point (before the user has finished
completing it)?

Therefore, is it possible to create a new record and immediately stop
additional records being added (only through clicking a button on the parent
form each time) to the subform when the user begins to edit the first new
record.

Many thanks.
Pete.
 
Use the AfterUpdate event of the subform's form to set .AllowAdditions to
False.
 
Thanks for the reply Ken.

I have actually done this but just wondered if there was a way to stop a new
blank record appearing when completing the initial new record.

Many thanks again.
Pete.
 
Back
Top