T
tompk
I've posted a couple times with no success but am probably not asking the
right questions. I have done a ton of searching online and think that what I
need to use is Insert Into however, I keep getting an error message and
programming is not my strong suit.
Essentially what I want is for the user to click search on a continuous
subform, search for the record they want and add it. The Search form is
built and works great by producing a list of records that the user can double
click to select the one they want however, I cannot figure out how to add the
record to my subform. Here's my setup:
Tbl_MAIN with Record_ID (PK)
Subtbl_Obligations_MAIN with Oblig_ID (PK)
Tbl_JUNCTION with Record_ID, Oblig_ID (for my many-to-many)
The main form in this instance is Frm_Obligations_MULTIPLES and the subform
is Frm_MAIN_MULTIPLES (probably not the best naming). The users need to be
able to add multiple Tbl_MAIN records to the Obligation. Both of the forms
are actually built off of a query of the respective tables, not the tables
themselves.
I found some code online which I have tried to modify for my own purposes:
Private Sub List_Results_DblClick(Cancel As Integer)
'Insert Record from main table into Frm_MAIN_MULTIPLES
Dim strSQL As String
strSQL = "INSERT INTO TBL_JUNCTION " & _
"(Oblig_ID, Record_ID) " & _
"VALUES(" & Forms!Frm_MAIN_MULTIPLES!Oblig_ID & _
", " Me.Record_ID & ")"
End Sub
I am not sure if I am even on the right track so I would really appreciate
if someone could advise. Additionally, I keep getting an "Expected end of
statement message" around the last two lines. I've tried playing around with
the "'s but am not getting anywhere.
From what I understand, my next step would be to put
Forms!Frm_Obligations_MULTIPLES!Frm_MAIN_MULTIPLES.Requery on After Insert.
True?
Thank you so much for any assistance you can provide
right questions. I have done a ton of searching online and think that what I
need to use is Insert Into however, I keep getting an error message and
programming is not my strong suit.
Essentially what I want is for the user to click search on a continuous
subform, search for the record they want and add it. The Search form is
built and works great by producing a list of records that the user can double
click to select the one they want however, I cannot figure out how to add the
record to my subform. Here's my setup:
Tbl_MAIN with Record_ID (PK)
Subtbl_Obligations_MAIN with Oblig_ID (PK)
Tbl_JUNCTION with Record_ID, Oblig_ID (for my many-to-many)
The main form in this instance is Frm_Obligations_MULTIPLES and the subform
is Frm_MAIN_MULTIPLES (probably not the best naming). The users need to be
able to add multiple Tbl_MAIN records to the Obligation. Both of the forms
are actually built off of a query of the respective tables, not the tables
themselves.
I found some code online which I have tried to modify for my own purposes:
Private Sub List_Results_DblClick(Cancel As Integer)
'Insert Record from main table into Frm_MAIN_MULTIPLES
Dim strSQL As String
strSQL = "INSERT INTO TBL_JUNCTION " & _
"(Oblig_ID, Record_ID) " & _
"VALUES(" & Forms!Frm_MAIN_MULTIPLES!Oblig_ID & _
", " Me.Record_ID & ")"
End Sub
I am not sure if I am even on the right track so I would really appreciate
if someone could advise. Additionally, I keep getting an "Expected end of
statement message" around the last two lines. I've tried playing around with
the "'s but am not getting anywhere.
From what I understand, my next step would be to put
Forms!Frm_Obligations_MULTIPLES!Frm_MAIN_MULTIPLES.Requery on After Insert.
True?
Thank you so much for any assistance you can provide