jegans

GIVING SEQUENTIAL NUMBERS TO A FIELD

Discussion created by jegans on Jun 21, 2010
Latest reply on May 25, 2015 by rfairhur24
How to give sequential numbers to a field, if we don't have sequential numbers for the Object ID and Field ID??

I found this question with one of my friends. So I thought it will be useful to others when I post in ESRI forum.

This is the solution for the issue.

NOTE: This is done by using VBA.
Select the field > Then R.Click on the Field > Go to Field calculator > Advanced > Copy and Paste the Code Given Below.

Static rec As Long

Dim pStart As Long

Dim pInterval As Long



' adjust start value if you want it to

' start at a value other than 1.

' For example, 1000.

' ====================================



pStart = 1



' adjust interval value if you want it to

' increment at a value other than 1.

' For example, 2.

' =======================================



pInterval = 1



If (rec = 0) Then

rec = pStart

Else

rec = rec + pInterval

End If
'========================
After pasting this code, type rec in the textbox below the VBA Code zone.

Then the ID will be calculated.
Hope this will be useful to all.
Thanks.(To All Motivating Me to Solve These Issues)

Outcomes