I have a field that is incremented by one when a new record occurs. The problem I'm having is that access sorts the table out of order when i exit the program and when i go to add a new record it tries to duplicate.
for example: it orders like this 1, 10, 2, 3, 4, 5, 6,7,8,9
and when i try to add a new record it should go to 11 but instead it continuosly tries to add 10 because the last field in the order is 9.
here is my code:
Private Sub Form_Current()
If Me.NewRecord Then
On Error Resume Next
Me!tran_ID.DefaultValue = Nz(DMax("[tran_ID]", "delivery", 0) + 1
End If
End Sub
Any Help would be greatly appreciated
for example: it orders like this 1, 10, 2, 3, 4, 5, 6,7,8,9
and when i try to add a new record it should go to 11 but instead it continuosly tries to add 10 because the last field in the order is 9.
here is my code:
Private Sub Form_Current()
If Me.NewRecord Then
On Error Resume Next
Me!tran_ID.DefaultValue = Nz(DMax("[tran_ID]", "delivery", 0) + 1
End If
End Sub
Any Help would be greatly appreciated