Question:
Why does Access say that the following information can't be used for a primary key?
JMD
2009-06-15 21:18:40 UTC
I am trying to create a database in Access using the SQL language which contains Information on various movies both past and present. This is a data file I have stuck in one of the tables:

Anaconda, 1997, Action/Adventure, "A National Geographic team must try to save their lives as they are pursued by a large, flesh-eating anaconda snake.", PG-13
Star Trek, 2009, Action/Adventure, "A film chronicling how the 'Star Trek' series began.", PG-13
Batman, 1989, Action/Adventure, "Batman saves Gotham City from his evil arch nemesis, the Joker.", PG-13
Batman Returns, 1992, Action/Adventure, "Batman returns in this trilling sequel to save Gotham City from the double threat of the Penguin and Catwoman.", PG-13
Bolt, 2008, Family, "The canine star of a hit tv show, who believes that his powers are real, embarks on a cross-country adventure to save his master from his evil nemesis.", PG
The Shining, 1980, Horror, "Based on the story by Stephen King, a family heads to an isolated hotel and must try to survive its menacing and lethal spirits.", R
Valkyrie, 2008, Thriller, "This film documents an operation by a group of Nazis to assassinate Hitler during WWII.", PG-13
Kill Bill vol. 1, 2003, Action/Adventure, "A dangerous assassin, known only as the Bride, goes around the world to exact revenge on her colleagues after they killed her family leaving her for dead.", R
Kill Bill vol. 2, 2004, Action/Adventure, "The second part telling of the Bride and her quest for bloody revenge.", R
The Dark Knight, 2008, Action/Adventure, "Batman must try to save Gotham City from the clutches of a newcoming villain, known only as the Joker.", PG-13
Paul Blart: Mall Cop, 2009, Comedy, "When a shopping mall is taken over by a gang of dangerous criminal, its up to Paul Blart, the mall security guard, to save the day.", PG
The Bucket List, 2007, Comedy, "Two terminally ill cancer patients try to do everything they ever wanted to do before they die.", PG-13
Batman Begins, 2005, Action/Adventure, "Director Chris Nolan directs this reimaging of how Bruce Wayne became Batman.", PG-13
The Incredible, 2004, Family, "Mr. Increbile and his superheroic family must save the world from the evil Syndrome.", PG
I Know What You Did Last Summer, 1997, Horror, "A group of teenagers are in danger from a madman they accidentally hit with their car and dump into a river one year ago during the summer.", R
I Still Know What You Did Last Summer, 1998, Horror, "Julie James and her friends, while spending time at a five star island resort, are in danger once again from the madman Ben Willis and his lethal games.", R
Gran Torino, 2008, Drama, "A disgruntled Korean war veteran tries to reform the child of his next door neighbor after he tries to steal his Gran Torino.", R
Casablanca, 1942, Drama, "The owner of a popular bar in the town of Casablanca must try to help his best friend and her husband escape from the evil clutches of the Nazis.", PG
The Wizard of Oz, 1939, Family, "Dorothy Gale tries to return to her home in Kansas after a tornado takes her to the mysterious and magical land of Oz.", G
Garfield: the movie, 2004, Family, "When Odie is kidnapped, it is up to Garfield and his friends to save the day.", PG
Halloween, 1978, Horror, "When homicidal mental patient, Michael Meyers, escapes from an Illinois mental hospital on Halloween night, its up to his doctor, Sam Loomis, to stop him.", R
Ghostbusters, 1984, Comedy, "The Ghostbusters try to save New York City (as well as the rest of the world) from the evil spirit Gozer.", PG
Ghostbusters II, 1989, Comedy, "The Ghostbusters reunite to try and save the world from the evil Veego and his minions.", PG
Raiders of the Lost Ark, 1981, Action/Adventure, "Indiana Jones leads an expedition to find the Ark of the Covenant before the Nazis do.", PG
Indiana Jones and the Temple of Doom, 1984, Action/Adventure, "Indiana Jones and his friends try to save a village in India by retrieving a stone stolen from the village and taken to the Temple of Doom.", PG


Now I have tried to make the primary key for this table a combination of both the film title and the year the said film was released in theaters, but every time I try to do this, Access provides a message that states "Index or Primary Key cannot contain a Null value". Can anyone out there tell me why this is happening and what I could do to fix this?
Three answers:
anonymous
2009-06-15 22:14:25 UTC
You are best off just adding an autoincrement column and assigning that as a primary key. It will work just fine.



To more directly answer the question you asked, without seeing your database, I can't give you a specific answer, except that the error message you get means exactly what it says: Somehow, when you try to create the primary key values, you are creating a null value for at least one record, and primary key fields cannot be null.



http://office.microsoft.com/en-us/access/HP051875241033.aspx



You might be best off using a template:



http://office.microsoft.com/en-us/templates/TC010186441033.aspx
anonymous
2016-04-09 05:17:46 UTC
You could do this in Excel. It would be clunky and require a lot more time maintaining though. Access is the best tool for this job. A primary key is a way to uniquely identify a record. Think of it this way.. there are thousands upon thousands of people named John Smith in this country.. but each of them has a unique social security number. The "basics" are a lot to answer in one post.. but here's some info that might help. The simplest solution to this request is to create a customer table and a complaint/remedy table. These will relate to each other through a customer number field in each. Breaking the data out like this is called normalization. It may seem counter productive, but it will save you so many headaches in the end. For example, let's say you have a contact field in your customer table and that contact changes.. if you had a single table you would have to update the contact in every single record dealing with that customer. But, with the tables split you only need to update it once. Access does a good job of providing wizards to do the functional stuff.. but it does nothing to help with design decisions. Also, you might want to drop in and say hi to your local IT staff. They may be willing to help you out here.
Daniel G
2009-06-15 21:35:49 UTC
SELECT *

FROM

WHERE IS NULL OR IS NULL



This will give you the reason why you are getting the message. Replace
with your table name; with your column name; and with the approriate column name.

This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...