Error on opening form of many-to-many relationship

P

Pamela

I have tblClaim with ClaimID (PK) and tblIntParty with PartyID (PK), both
Autonumber fields, which needs to be a many-to-many as each claim can have
several parties and each party can have multiple claims. I, therefore, made
a junction table tblClaimIntParty with both the ClaimID and PartyID as a dual
PK. I now have a command button on frmClaim to open frmIntParty but am
getting the error "Cannot add record(s); join key of table 'tblClaimIntParty'
not in recordset." I noticed that when the frmIntParty opens, it still shows
"Autonumber" in the PartyID field. Nothing I've found yet on junction tables
tells you what further to do with it... any help would be great!!

Here is the code for the command button:
Private Sub CBOpenIntParty_Click()
On Error GoTo Err_CBOpenIntParty_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmInterestedParty"

stLinkCriteria = "[ClaimID]=" & Me![ClaimID]
DoCmd.OpenForm stDocName, , , , acFormAdd, , Me![ClaimID]

Exit_CBOpenIntParty_Click:
Exit Sub

Err_CBOpenIntParty_Click:
MsgBox Err.Description
Resume Exit_CBOpenIntParty_Click

End Sub

Here is the code for the OnLoad event of the frmIntParty:
Private Sub Form_Load()
Me.ClaimID = Me.OpenArgs

End Sub

TIA!
Pamela
 
P

Pamela

The recordsource is a query that has tblIntParty and the junction table
joined as a one-to-many. Thanks, in advance, for assisting me with this!

Beetle said:
What is the recordsource of "frmInterestedParty"?
--
_________

Sean Bailey


Pamela said:
I have tblClaim with ClaimID (PK) and tblIntParty with PartyID (PK), both
Autonumber fields, which needs to be a many-to-many as each claim can have
several parties and each party can have multiple claims. I, therefore, made
a junction table tblClaimIntParty with both the ClaimID and PartyID as a dual
PK. I now have a command button on frmClaim to open frmIntParty but am
getting the error "Cannot add record(s); join key of table 'tblClaimIntParty'
not in recordset." I noticed that when the frmIntParty opens, it still shows
"Autonumber" in the PartyID field. Nothing I've found yet on junction tables
tells you what further to do with it... any help would be great!!

Here is the code for the command button:
Private Sub CBOpenIntParty_Click()
On Error GoTo Err_CBOpenIntParty_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmInterestedParty"

stLinkCriteria = "[ClaimID]=" & Me![ClaimID]
DoCmd.OpenForm stDocName, , , , acFormAdd, , Me![ClaimID]

Exit_CBOpenIntParty_Click:
Exit Sub

Err_CBOpenIntParty_Click:
MsgBox Err.Description
Resume Exit_CBOpenIntParty_Click

End Sub

Here is the code for the OnLoad event of the frmIntParty:
Private Sub Form_Load()
Me.ClaimID = Me.OpenArgs

End Sub

TIA!
Pamela
 
P

Pamela

After first responding, I thought about your post and so checked the
recordsource and found that I had only added PartyID from the "many" table so
I tried also adding it from the "one" table in the one-to-many relationship
and this appears to have worked...so thanks for your response, it got me
where I needed to go... : )

Beetle said:
What is the recordsource of "frmInterestedParty"?
--
_________

Sean Bailey


Pamela said:
I have tblClaim with ClaimID (PK) and tblIntParty with PartyID (PK), both
Autonumber fields, which needs to be a many-to-many as each claim can have
several parties and each party can have multiple claims. I, therefore, made
a junction table tblClaimIntParty with both the ClaimID and PartyID as a dual
PK. I now have a command button on frmClaim to open frmIntParty but am
getting the error "Cannot add record(s); join key of table 'tblClaimIntParty'
not in recordset." I noticed that when the frmIntParty opens, it still shows
"Autonumber" in the PartyID field. Nothing I've found yet on junction tables
tells you what further to do with it... any help would be great!!

Here is the code for the command button:
Private Sub CBOpenIntParty_Click()
On Error GoTo Err_CBOpenIntParty_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmInterestedParty"

stLinkCriteria = "[ClaimID]=" & Me![ClaimID]
DoCmd.OpenForm stDocName, , , , acFormAdd, , Me![ClaimID]

Exit_CBOpenIntParty_Click:
Exit Sub

Err_CBOpenIntParty_Click:
MsgBox Err.Description
Resume Exit_CBOpenIntParty_Click

End Sub

Here is the code for the OnLoad event of the frmIntParty:
Private Sub Form_Load()
Me.ClaimID = Me.OpenArgs

End Sub

TIA!
Pamela
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top