Auto Num code question

Mojo1

Board Regular
Joined
Mar 6, 2003
Messages
148
I have a db where when you add a new record on the form you are not assigned a new auto number. I have a backup db where it does work yet I can not see what is different. Would it have to in the table design that is the data source for the form? or something else. The code that generates this look similiar to me.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Have you looked at the table that the form is bound to to see whether or not an Autonumber is being added? Sometimes, a developer will design a form with the Autonumber text field being invisible since it's usually not that useful to the user. If this isn't the case, check your data type in the table for the field that's supposed to be an Autonumber and make sure that it has been declared Autonumber rather than Number or something else.
 
Upvote 0
Here is the code for the auto number

Private Sub Form_Current()
If Me.NEWRECORD Then
On Error Resume Next
Me.NMMI_NUM = "A" & pad_zeros(Val(Mid$(DMax("[NMMI_NUM]", "NMPHY"), 2)) + 1, "right", 6)
End If

End Sub

This is a number where there is a A0##### since there is already records in the db with this. NMMI_NUM is the field we are incrementing, and NMPHY is the table.

This works on an older version of the db but not on the current version. So that is why I have asked where to look.
 
Upvote 0

Forum statistics

Threads
1,223,441
Messages
6,172,139
Members
452,445
Latest member
walkman99

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