AddNew with Junction Table causing Grief?

C

carriey

Had some help with this, went and bought a book (which is still a bit greek
to me), and have played around some with the code. I have a main form with a
subform within a subform that when the user clicks on a button, it will add a
new record to another subform (with a subform inside that)

I thought the best bet would be just to ignore those second subforms for now
and get the one subform (well, table) to update to make sure that I actually
get it right.

I keep getting Runtime Error 2465 - Access can't recognize Record_ID. I
think it's because I have a Junction Table for a many-to-many but I'm not
sure how to allow for that? And it's entirely possible that I'm off-base
with that assumption.

Main Form: Frm_MAIN_AB (PK: Record_ID)
Subform: Frm_Internal_Inspections (PK: IntInsp)

I want to update Subtbl_Obligations_MAIN (PK: Oblig_ID) which is linked to
the main table through TBL_JUNCTION (Record_ID and Oblig_ID).

Could anyone tell me how I might fix this?

Private Sub cmd_send_sd_ab_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("Subtbl_Obligations_MAIN", dbOpenDynaset)

rs.AddNew

rs!Record_ID = Me!Record_ID <-----HERE'S MY ERROR

rs!Oblig_Date = Me!Frm_MAIN_AB!Frm_Internal_Inspections.Form!Int_Insp_Date
rs!Oblig_Date = Date
rs!Oblig_Status = "Open"
rs!Response_Due = Me!Frm_MAIN_AB!Frm_Internal_Inspections.Form!Response_Due
rs!Employee = Me!Frm_MAIN_AB!Frm_Internal_Inspections.Form!Employee
rs!Oblig_Type = "Self Declaration"
rs!Int_Classification = "Yes"
rs.Update
rs.Close
Set rs = Nothing

End Sub


Thank you!!!!!!
 

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