p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: null Value error


Message #1 by "Howard Stone" <ququmber@h...> on Mon, 24 Jun 2002 07:36:14
I am having a problem that I am unable to figure out.  I have the 
following tables, tblCustomer, tblVisit and tblVisitDetails.
tblCustomer relates to tblVisit in a 1-many relationship and tblVisit 
relates to tblVisitDetails in a 1-many relationship.  The CustomerID field 
from tblCustomer is the foreign key in tblVisit and VisitID field is the 
foreign key in tblVisitDetails

I create a from and subform using tblVisit and tblVisitDetails by using 
the CustomerID field in tblVisit (and the other not mentioned fields )  
and the fields in tblVisitDetails.

I notice that after entering a record in tblVisitDetails and updating and 
now try to add another record I get an error message, ?Index or primary 
key cannot a null value?.  I can add any mumber of records to 
tblVisitDetails but once I move to a new record and come back I get the 
error.

I thought it was because I did not directly use tblCustomer and create a 
form with tblCustomer as the main form and tblVisit and tblVisitDetails as 
subforms.  On trying this way I still get the same error.  I am completely 
baffled as to what is causing the problem.

Can someone help me on this?

Thanks
Message #2 by "Amy Wyatt" <amyw@c...> on Mon, 24 Jun 2002 13:31:19
I think I need a little more information. What is the record source of the 
main form? Are there 2 subforms or just one or is it a subform in a 
subform in a main form (nested).

I suspect that the problem lies in the subforms. In Access, in certain 
situations, adding a record to a subform will automatically add the 
correspoding primary key that links the two forms to each other. However, 
under many circumstances this does not work and has to be handled throught 
code. Have you checked the data being added to make sure it is entering 
the correct primary key for the appropriate tables?

Amy


> I am having a problem that I am unable to figure out.  I have the 
f> ollowing tables, tblCustomer, tblVisit and tblVisitDetails.
t> blCustomer relates to tblVisit in a 1-many relationship and tblVisit 
r> elates to tblVisitDetails in a 1-many relationship.  The CustomerID 
field 
f> rom tblCustomer is the foreign key in tblVisit and VisitID field is the 
f> oreign key in tblVisitDetails

> I create a from and subform using tblVisit and tblVisitDetails by using 
t> he CustomerID field in tblVisit (and the other not mentioned fields )  
a> nd the fields in tblVisitDetails.

> I notice that after entering a record in tblVisitDetails and updating 
and 
n> ow try to add another record I get an error message, ?Index or primary 
k> ey cannot a null value?.  I can add any mumber of records to 
t> blVisitDetails but once I move to a new record and come back I get the 
e> rror.

> I thought it was because I did not directly use tblCustomer and create a 
f> orm with tblCustomer as the main form and tblVisit and tblVisitDetails 
as 
s> ubforms.  On trying this way I still get the same error.  I am 
completely 
b> affled as to what is causing the problem.

> Can someone help me on this?

> Thanks

  Return to Index