Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Index or primary key cannot contain a Null value (Error 3058

Status
Not open for further replies.

coyote1

IS-IT--Management
Nov 16, 2006
55
I am currently working on a Access db that tracks properties and owners. It has a many to many relationship between the property and owner tables. It has a subform for "current owners" which I am able to see the current owner(s) of that property, re-assign owner(s) and add additional owner(s). My problem is that when I add a new property through the main form then go to the subform to add an owner I get an error message "Index or primary key cannot contain a Null value (Error 3058)" Does anybody know of a good approach to troubleshooting this error message?

Any help is appreciated !


ksr
 
i geuss you made a primary key but you didnt assign a value to that if you can add a field with an autonumber and make that as your primary key

I will try my best to help others so will others do!!!!!
IGPCS
Brooklyn, NY
 
Thanks for the reply,

Please let me clarify a few things. I have primary keys that have autonumbers as the data type in both the "owners" and "property" tables. These tables are related through a juntion table that has FKs from both of these primary keys. My sub forms is based on a query with the following SQL view:

SELECT tblOwners.*, tblLINKProperty_Owners.*
FROM tblOwners INNER JOIN tblLINKProperty_Owners ON tblOwners.ID = tblLINKProperty_Owners.Owners_ID;

From this query the subform record source provides fields for the subform such as name, adress, phone number etc.

If I enter data directly into the properties table then go back to the form the assigned owner exists with no error messages.




 

Sounds like you don't have a value assigned to the new property primary key (owner-id) when you first create it.

How about....

1. Create a "dummy" owner.
2. Make the "dummy" owner the default for the properties table.
3. When you create the new property, it should appear on your subform with the "dummy" owner listed.
4. Change the owner to the correct value.



Randy
 
Randy, Sounds interesting.
Tried to go about creating this "Dummy" owner default for the tblProperties. Seem to need some direction. Did you mean the tblLINKProperty_Owners (juntion table)?

Thanks,

Karl
 

Sorry, I didn't notice you were using a LINK table. I was thinking about a 1 to 1 relationship between owners and properties.

What is the primary key for your LINK table?
If it's a combination of the OwnerID and PropertyID, that could be your problem. You may be putting a value of the new property into the LINK record without a value in the ownerID field. If you had a "dummy" owner (maybe a "dummy" property as well), you could use that value in your new LINK record until it can be updated in the subform.

However, I think a better method would be to add an autonumber field to the LINK table and make it the primary key. This would alleviate the problem of having a null value assigned to the primary key and you can still enter the owner in the subform.


Randy
 
Randy,

I did as suggested and it seems to work.

re:
>However, I think a better method would be to add an >autonumber field to the LINK table and make it the >primary key. This would alleviate the problem of having a >null value assigned to the primary key and you can still >enter the owner in the subform.

Question:
With the addition of a seperate autonumber primary key the FKs in the LINK table were as you know origonally a composite primary key and now are not (not unique).With this modification my belief is that the many to many relationship will be maintained and the new primary key will provide the uniqueness (no dulicates) Does this make since?

Thanks

Karl
Not paranoid just being carefull



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top