One-to-many relationship failing

josephbupe

Registered User.
Local time
Today, 19:51
Joined
Jan 31, 2008
Messages
247
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
 

Attachments

First of all you need to change this:

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

to this:

stLinkCriteria = "[CaseID]=" & Me![CaseID]
 
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.
 
Ok,

Let me go through again.

Joseph
 
Last edited:
Thanx for your help.

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

Stay well.

Joseph
 

Users who are viewing this thread

Back
Top Bottom