View Single Post
 
Old 10-19-2015, 11:00 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your initial post described IDs being incremented every time you insert a new data set, but without regard to any existing sequencing. That's what the code I supplied provides for.

Your code, however, envisages searching through the document for all existing IDs (which could be a slow process in a long document) to find the highest one (which might not be the last one allocated if that one has since been deleted), then (apparently) you intend to sequentially add successive IDs to data presently lacking them.

The two approaches are quite different and yours doesn't really meet your "every time I insert a new data set" criterion.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote