Can't add a record

Mojo1

Board Regular
Joined
Mar 6, 2003
Messages
148
I have a form that will not allow you to add a new record without an error. Here is the code I have to auto generate a new number

Private Sub Form_Current()
If Me.NEWRECORD Then
On Error Resume Next
Me.CS_NUM = Nz(DMax("[CS_NUM]", "dbo_INV_INFSVC"), 0) + 1
End If
End Sub

I have number 1-4574 and then it goes 493 thru 999 and the next number in line to add is 1000 which already exists in the 1-4574 range. Is there a way to manipulate the code above so that it will add the next available number?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,532
Messages
6,172,881
Members
452,486
Latest member
standw01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top