Tim Bedborough
Registered User.
- Local time
- Today, 09:35
- Joined
- Nov 16, 2015
- Messages
- 42
Hi all Please can you advise on following. When I add a new linked invoice to a customer record for the first time it only works if I use - Recordset.AddNew If there are already linked records then this works fine - DoCmd.RunCommand acCmdRecordsGoToNew BUT If I use Recordset.AddNew the primary key in the underlying table misses a number, e.g. 1,3,5,7 etc. This doesn't happen when using acCmdRecordsGoToNew So to reduce missing primary key numbers I came up with the following On Current event procedure. Private Sub Form_Current() If Me.subfrmInvoiceNew.Form.RecordsetClone.RecordCount = 0 Then Me.subfrmInvoiceNew.Form.Recordset.AddNew Forms![frmInvoiceNew]![subfrmInvoiceNew].Form![RaisedBy] = Forms![frmpassword].Form![EmployeeName] Else Me.subfrmInvoiceNew.SetFocus DoCmd.RunCommand acCmdRecordsGoToNew Forms![frmInvoiceNew]![subfrmInvoiceNew].Form![RaisedBy] = Forms![frmpassword].Form![EmployeeName] End If End Sub Please can you advise on : 1. Does it matter which 'new record' code I use 2. Does it matter that the primary key misses a number 3. Has anyone got any better suggestions for code please From 'Googling' so far I think I've drawn the conclusion I can use either and it doesn't matter if the primary key jumps a number (although doesn't seem quite right to me). Thanks