Assign a Unique ID # Automatically to Members

Can ya’ll tell I am working on my databases today for my new website? LOL Sorry for the number of questions. I am trying to figure out if there is a way to automatically assign a unique ID # to the new members that sign up to participate in an elementary school health challenge. I need to be able to track them across multiple programs and a unique ID # would help me to do that. Any thoughts on how I might best accomplish that? It will be hundreds of people, so manually assigning them is unrealistic.

Does the ID have to be a running number (1, 2, 3, …) or can it be any unique string?

1 Like

Consecutive would be fantastic, but I would definitely settle for unique string (and something that isn’t going to overwhelm them to remember).

just create a field in your collection named UNIQUE_ID and when creating new records get the last record in your collection, like 5678 and increment that with 1 and store it. If you run a query in the before save to check if the calculated value exists and if it exists, increment it again and retry save. This way you should get some kind of autoincrement. Otherwise creating a GUID for every one is the best but not that read-friendly for you.

2 Likes

What Andreas wrote would work… in all but very rare cases.
by the way, how many records do you plan to keep in your collection?

2 Likes

It would be for people who choose to sign up for the gym online instead of in person, so, over time, it potentially could be several hundred to several thousand.