Ben_Entrew
Registered User.
- Local time
- Today, 05:32
- Joined
- Dec 3, 2013
- Messages
- 177
Hi all,
I want to modify a table called FC_TEMP via adding some columns from another table called AVERAGE_TRP. Do I have to create a new query table and then insert the output into a new table?
The following code shows me : Cannot execute a selected query.
Is there a way to update this FC_TEMP table without creating another temporary table?
Thanks in advance.
Regards,
Ben
I want to modify a table called FC_TEMP via adding some columns from another table called AVERAGE_TRP. Do I have to create a new query table and then insert the output into a new table?
The following code shows me : Cannot execute a selected query.
Is there a way to update this FC_TEMP table without creating another temporary table?
Thanks in advance.
Regards,
Ben
Code:
Public Sub Update()
Dim strSQL As String
strSQL = "SELECT FC_TEMP.*,AVERAGE_TRP.[Average_new_TRP_EUR],AVERAGE_TRP.[Average_old_TRP_EUR],AVERAGE_TRP.[Average_Margin] " & _
" FROM FC_TEMP " & _
" INNER JOIN AVERAGE_TRP ON FC_TEMP.[PRODUCT_ID] = AVERAGE_TRP.[PRODUCT_ID]"
CurrentDb.Execute strSQL
DoCmd.RunSQL "UPDATE FC_TEMP SET FC_TEMP.[new_TRP_2013_in_EUR] = FC_TEMP.[Average_new_TRP_EUR] " & _
" WHERE FC_TEMP.[new_TRP_2013_in_EUR] is Null"
DoCmd.RunSQL "UPDATE FC_TEMP SET FC_TEMP.[old_TRP_2013_in_EUR] = FC_TEMP.[Average_old_TRP_EUR] " & _
" WHERE FC_TEMP.[old_TRP_2013_in_EUR] is Null"
DoCmd.RunSQL "UPDATE FC_TEMP SET FC_TEMP.[Margin] = FC_TEMP.[Average_Margin] " & _
" WHERE FC_TEMP.[Margin] is Null"
End Sub