A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

AddNew with Junction Table causing Grief?



 
 
Thread Tools Display Modes
  #1  
Old November 12th, 2008, 09:36 PM posted to microsoft.public.access.tablesdbdesign
carriey
external usenet poster
 
Posts: 22
Default AddNew with Junction Table causing Grief?

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_I nsp_Date
rs!Oblig_Date = Date
rs!Oblig_Status = "Open"
rs!Response_Due = Me!Frm_MAIN_AB!Frm_Internal_Inspections.Form!Respo nse_Due
rs!Employee = Me!Frm_MAIN_AB!Frm_Internal_Inspections.Form!Emplo yee
rs!Oblig_Type = "Self Declaration"
rs!Int_Classification = "Yes"
rs.Update
rs.Close
Set rs = Nothing

End Sub


Thank you!!!!!!
  #2  
Old November 12th, 2008, 11:12 PM posted to microsoft.public.access.tablesdbdesign
carriey
external usenet poster
 
Posts: 22
Default AddNew with Junction Table causing Grief?

Sorry I posted this to the wrong group - I will repost!

"carriey" wrote:

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_I nsp_Date
rs!Oblig_Date = Date
rs!Oblig_Status = "Open"
rs!Response_Due = Me!Frm_MAIN_AB!Frm_Internal_Inspections.Form!Respo nse_Due
rs!Employee = Me!Frm_MAIN_AB!Frm_Internal_Inspections.Form!Emplo yee
rs!Oblig_Type = "Self Declaration"
rs!Int_Classification = "Yes"
rs.Update
rs.Close
Set rs = Nothing

End Sub


Thank you!!!!!!

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:09 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.