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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error: a index or primary key can't contain a Null_value

Status
Not open for further replies.
Mar 27, 2002
168
NL
I have a simple form subform construction
form: table fk_werknummer as primary key
subform: table product_id as primary key,
fk_werknummer as foreign key

I open the form based on a value for fk_werknummer
when I enter the subform the follow error occur:
a index or primary key can't contain a Null-value

anybody know how it's possible?
thnx in advance,
gerard
 
Do you have fk_werknummer in the subFormControl's LinkParentFields and LinkChildFields properties ?

Do you have the two table linked in the Relationship window with Referential Integrity established?

Is fk_werknummer in the main table an AutoNumber ?



G LS
 
It seems to me like you're somehow editing/inserting a row in the main table when you go to the subform, but without entering a value in the primary key field(s).

A primary key in Access has exactly this behaviour:
1. It must exist
2. It must be unique

Make sure you have the primary key entered in the record before going to the subform.
You can check if everything is OK by pressing Shift+Enter (Save Record)...
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
I'll try shift_enter, but same error comes up:
MainTable: fk_werknummer (primairy key, txtfield)
subtable: ID (autonumber), fk_werknummer (foreign key)

I push the primairy key programmatically in the field on the form which correspond with the maintable, maybe here is something wrong. I have to use a insert Query maybe?

Thnx for all help,

Gerard
 
Programatically....
What's the code?
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Just fix it, the problem was: foreign key was a unbound textfield. Don't know how it's possible but it was happen
Now I take an insert query on the button which open the neccesary form. That's it...

thnx for al reactions,

gerard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top