Copy data from one subform into another

J

JKarchner

I have a subform that is uses a query called 'qryModelsXREF'. This subform
shows what part is supplied by whom on the product. The product is the basis
for the main page. So each record on the main form shows one product and has
a subform that displays all the parts and who they are supplied by for that
product. What i would like to do is add another subform based on a query
called 'qryCategoryAParts' that displays information regarding parts from
categoryA. How would i go about coding it so that when a part is added to
the first subform it is also added to the second subform? I hope this is
clear enough to understand, but if need be i can try to clarify for you.
Thank you in advance for all of your help.
 
J

JKarchner

Ok, i figured this out on my own, using bits of code found on this community,
so thank you to everyone out there who helped. The code to solve my problem
and also to requery the result is as follows:

Private Sub Form_AfterInsert()
If Me.SupplyPartCategory = "Window" Then
Dim SQL As String
SQL = "INSERT INTO qryWWindowsXREFModels (Model_ID, SupplyPart_ID)
VALUES (" & Me.Model_ID & ", " & Me.SupplyPart_ID & ")"
DoCmd.RunSQL SQL
Me.Parent.[subFrmWQryWindows(New)].Form.Requery
End If
End Sub


Of course the 'SQL =' line all appears on a single line when typed out.
 
J

JKarchner

Sorry i forgot to add that my problem has some what evolved. What i would
like to have happen is that the entry will only be inserted if the new record
is unique. How would i go about checking if there are any duplicates that
exist in qryWWindowsXREFModels? The fields i need to use are Model_ID, and
SupplyPart_ID. Thank you for any help.

JKarchner said:
Ok, i figured this out on my own, using bits of code found on this community,
so thank you to everyone out there who helped. The code to solve my problem
and also to requery the result is as follows:

Private Sub Form_AfterInsert()
If Me.SupplyPartCategory = "Window" Then
Dim SQL As String
SQL = "INSERT INTO qryWWindowsXREFModels (Model_ID, SupplyPart_ID)
VALUES (" & Me.Model_ID & ", " & Me.SupplyPart_ID & ")"
DoCmd.RunSQL SQL
Me.Parent.[subFrmWQryWindows(New)].Form.Requery
End If
End Sub


Of course the 'SQL =' line all appears on a single line when typed out.
JKarchner said:
I have a subform that is uses a query called 'qryModelsXREF'. This subform
shows what part is supplied by whom on the product. The product is the basis
for the main page. So each record on the main form shows one product and has
a subform that displays all the parts and who they are supplied by for that
product. What i would like to do is add another subform based on a query
called 'qryCategoryAParts' that displays information regarding parts from
categoryA. How would i go about coding it so that when a part is added to
the first subform it is also added to the second subform? I hope this is
clear enough to understand, but if need be i can try to clarify for you.
Thank you in advance for all of your help.
 
Top