The code is located the Before Update event of the form (frmEnterNewStockItems). Open the form in Design View then go to the property sheet-->Event tab--> Before Update and then click in the line where you see Event Procedure. A button with three dots (...) will show up to the right, click on the button and you will be taken to the code window.
The following is the actual code. The Me.xxxxx refers to a control on the form.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim holdcount As Long
holdcount = DCount("*", "tblStock", "fkCatID=" & Me.cboCat)
Debug.Print holdcount, Me.cboCat
If DCount("*", "tblStock", "fkCatID=" & Me.cboCat) = 0 Then
Me.longSeqNo = 1
Else
Me.longSeqNo = DMax("longSeqno", "tblStock", "fkCatID=" & Me.cboCat) + 1
End If
End Sub