• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 515
  • Last Modified:

Set primary key to random number for version 2010

I want to set primary key for random numbers.  I could set the 'New Values' field property on Access 2003 but I don't see it on 2010 version.  Is there another way to do this?

Thanks
0
zpotok
Asked:
zpotok
  • 2
  • 2
  • 2
  • +1
3 Solutions
 
lee555J5Commented:
In table design mode, highlight the primary key field. In the bottom properties section, set the New Values property to Random.

Lee
0
 
Aaron TomoskySD-WAN SimplifiedCommented:
I don't suggest having random numbers or guids as PKs. Lookup uuid as Pk or guid as Pk and you will find discussions on how it messes up indexing, slows down queries, etc...
Can I ask why you need a random Pk and not a autoincrement Pk?
0
 
zpotokAuthor Commented:
Unless I'm looking at this wrong - There isn't a property called New Field as I stated in my question.

I see your point on indexing and all.  I just didn't want to start off with 1, 2, etc.  does auto increment have to start as 1,2 etc?  
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
lee555J5Commented:
Have you set your DataType to AutoNumber and your Field Size to Long Integer?

Lee
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
If your database is designed correctly, then the value of your AutoNumber field should have no impact on the data, so it shouldn't matter whether Jet/ACE assigns a value of 1 or 146,244 to a record. The AN field should ONLY be used as a surrogate index for a record - you should still set a Unique index to ensure data uniqueness (the AN field should have NO bearing on that). If your AN field has some sort of "value" to the record, then I'd suggest you might be using the AN field incorrectly.

Note you can "seed" the AN field like this:

Currentdb.Execute "INSERT INTO YourTable(YourANField) VALUES(3000)"

Compact the database, and YourTable.YourANField would begin the count at 3001.


0
 
Aaron TomoskySD-WAN SimplifiedCommented:
With mssql an mysql you can change the value of thenext auto increment, I don't know if you cando this in access but it should be somewhere. I like to reset mine to 0 when I'm testing imports.
0
 
zpotokAuthor Commented:
Thanks...good discussion
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now