Can anyone help me here? I am trying to do a user defined autonumber when I click on a button. The code worked fine when the recordset is empty, it give me a 1 on my first record, however, after I click on the button again, it give me 1 again. Here's my code.
Private Sub BtnNew_Click()
Dim rsClone As Recordset
Dim pVal As Integer
Set rsClone = Me.RecordsetClone
If Not (rsClone.BOF) Then
DoCmd.GoToRecord , , acNewRec
rsClone.MoveLast
pVal = rsClone.AbsolutePosition + 2
Me.CatgId.Value = pVal
Me.CatgId.SetFocus
Else
rsClone.AddNew
Me.CatgId.Value = 1
Me.CatgId.SetFocus
End If
End Sub
Thanks for the help.