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 SkipVought 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 can't be null value when I click a new record??

Status
Not open for further replies.

qajussi

Programmer
Mar 22, 2004
236
0
0
US
Hi!

I have a main form(tabbed) with subforms on each of the tabbed forms.

I can navigate bewteen records but as soon as I click a create a new record button, I get this error "index or primary key can't be null value" and can't locate where it is coming from.

I am navigating through from the main form.

I looked through each of the subforms and can't locate where I need to fix.

Main form is called "facilityMaster"
facilityMaster has three tabs(tab1, tab2, tab3)
When open up the facilityMaster form,
it opens up at tab1 which has sub form(subAddress)

I am not sure if I gave you enough details.

Where is this error coming from? and how can I fix this?
Please help.
Thanks a lot.

Q

 
In one of your tables you set the primary key as Required, in other words, it cannot be null or empty in order to go to another form.

You need to have data in the primary key in your form or go to the design view of your table and set the primary key to Required=No.
 
I hit the new record button it creates the primary key in the table automatically behind the access since i don't write any code to do the insert. it has been working fine.
I just can find the exact location to trap this error.
Only place I do any insert in when they fill in the forms on the subforms..

I don't know where to look to trap the error(where it is coming from.

Other things is even though i get the error,it creates the primary key and saves the main forms information on the table but not subform informations.

If subform is the problem why am I not getting the error from the subform error trapping which I put in.
Thanks again.
 
Hi qajussi,
Maybe delete the subform that gives the error, then recreate the subform and set the child & masterfield again



Pampers.

You're never too young to learn
 
Thanks guys.

I don't know where the error is coming from.
It happens when I click a new record from the main page.

I can do whatever on subforms and other tabs until I hit the new records button.

ANyone knows what is going here??
Thanks.

Q
 
Check the indexes and columns on all of your tables for the following:

1. Primary keys are autonumber columns. (Not specifically required, but if they are not user entered values, this can be a source of your problem.)
2. Be sure that all other indexes and columns allow nulls.
3. Also check that all other indexes are not defined as unique values. (There are cases where unique would be correct, but Access tends to default to this requirement in many cases where you do not wnat unique values.)

Bob
 
BSman,

My primary key's data type is GUID so they have to be unique.

Is it ok to make indexes to be nulls?

I can't find this error...
I am lost where to look.
Thanks so much for your input.

Q
 
If I dont get a problem, i go back to the beginning. I temproraty break the links between the tables in relationship view/querys. I look at the table where the mainfrom is attached to. Enter mannualy a new record. Make sure the primary key GuIDis autonumbered.

If this all works fine, redifine a first relationship; make sure the foreign key are set right. Make sure the relationship is correct (1:n or 1 to 1; referantial entigriy etcc) Again, enter a testrecord in your 'main' table and one in the related table..etc... Make sure it works properly, etcc...
Hope this helps


Pampers.

You're never too young to learn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top