View Full Version : One-to-many relationship failing


josephbupe
06-02-2010, 07:38 AM
Hi,

I think my table relationship is set well. But why the Foreign Key is not populating I don't know. Please, help.

TBL_Cases (CaseID=PK)
TBL_CaseNotes (CaseNoteID=PK, CaseID=FK)

FRM_FileCases is the mainform with only two cases and the details form (FRM_CaseNotes) with the CaseID=FK in question should be accessed on-click of the "details" button on the main form.

I will appreciate your help.

Joseph

boblarson
06-02-2010, 07:50 AM
First of all you need to change this:

stLinkCriteria = "[CaseNoteID]=" & Me![CaseID]

to this:

stLinkCriteria = "[CaseID]=" & Me![CaseID]

boblarson
06-02-2010, 07:58 AM
Also, the other thing is that if you are going to ADD a new note (since you aren't using it as a subform) you will have to populate the CaseID field in the form (for a new note) yourself either manually or with code. For existing notes it is fine but you will need something like:

[code]
Private Sub Form_Load()
If Me.NewRecord Then
Me.CaseID = Forms!FRM_FileCases.FRM_PackDtlSubForm.Form!CaseID
End If
End Sub [code]

You will also then need to ensure that if the record is not completed that it gets discarded or else you will end up with a lot of blank records.

josephbupe
06-02-2010, 08:15 AM
Ok,

Let me go through again.

Joseph

josephbupe
06-03-2010, 11:28 AM
Thanx for your help.

I made the details form a subform and it works just fine.

Stay well.

Joseph