View Single Post
  #5  
Old March 17th, 2010, 11:45 PM posted to microsoft.public.access.tablesdbdesign
dynamic dd[_2_]
external usenet poster
 
Posts: 3
Default Referential integrity and updating primary key



"Tom van Stiphout" wrote:

On Wed, 17 Mar 2010 12:23:01 -0700, dynamic dd
wrote:

You need a primary key in every table. Please add one right now. If
you can't think of a better one, simply add an Autonumber ID field.

Next your mainform. It needs to be bound to tblInmates (I'm using a
more standard naming convension as a suggestion to you. Single words
without funny characters so I don't have to use square brackets all
the time). If the user wants to enter some medical record, she first
finds the inmate record, for example Ctrl+F on the CDCR_No field.

The subform is bound to tblMedical. In the Relationships window you
drew the line between tblInmates.CDCR_No and tblMedical.CDCR_No, and
checked the box to enforce it. This is a critical step for data
integrity. Cascading updates can be off, because (I assume) CDCR_No is
a fixed inmate number that does not change.

The subform control has two critical properties: LinkMasterFields and
LinkChildFields. Set both of them to CDCR_No.
On the subform, drag the CDCR_No to the Header section of the form.
This will hide it when running in datasheet view. If you are using
another form view, make the field invisible. This is also a critical
step: the user is NOT to enter data in this field. It is only there
for the db engine to link the parent table to the child table.

Now you have the classic 1:M form set up, and it will work fine. When
a new inmate arrives, use the VCR buttons at the bottom of the form to
navigate to a new record. Fill out the CDCR_No and other fields on the
main form. Then medical records can be added (first the parent, then
the child).

HTH,

-Tom.
Microsoft Access MVP




I have Access 2000 on the job.
I have two tables [Inmate Demographics] (CDCR#, Last Name, First Name, and
DOB are the only fields) and [7362 Tracking] with many medical related
fields.

[Inmate Demo] Primary Key = ‘CDCR#’
[7362 Tracking]. No Primary Key

One [Inmate Demo] to many [7362 Tracking] relationship on ‘CDCR#’
Referential Integrity is checked with cascading updates

I have a form
Inmate Demographics is the main form with Record Source [Inmate Demographics]
7362 Tracking1 is the sub form with Record Source [7362 Tracking]

I set this up this way because the user wanted to be able to input the CDCR
number and have the rest of the inmate demographics pulled up (names and
DOB). This feature works as planned however, now I can’t add new records on
the Inmate Demo form. Here is the error message I am getting: “The
Microsoft Jet database engine cannot find a record in the table ‘Inmate
Demographics’ with key matching fields(s) ‘CDCR#’. I understand the reason
is that I have not previously entered the data in the table.
How can I get the update done on the Inmate Demographics form? I really am
frustrated and in need of help.

.
Tom,

I'm working on implementing the changes you suggested and will let you know
when I am finished. Thank you very much.

Dianne