Ben_Entrew
Registered User.
- Local time
- Today, 12:39
- Joined
- Dec 3, 2013
- Messages
- 177
Hi all,
I'm not sure if this is possible. I want to replace some values in a TNS_QUERY with DSUM.
The error message tells me I have to use an updateable table.
How can I avoid to create a query and replace the values directly in the original table TNS? I just group on the original table.
Thanks in advance.
Regards,
Ben
I'm not sure if this is possible. I want to replace some values in a TNS_QUERY with DSUM.
The error message tells me I have to use an updateable table.
How can I avoid to create a query and replace the values directly in the original table TNS? I just group on the original table.
Thanks in advance.
Regards,
Ben
Code:
Public Sub TNS_QUERY()
Dim strSQL As String
Dim x As Double
Dim qdf As QueryDef
strSQL = "SELECT TNS.[Division],TNS.[Customer_Split],SUM([TOTAL_NET_SALES]) as [Total_Net_Sales_in_EUR],TNS.[Reporting_Month] " & _
" FROM TNS " & _
" WHERE [Total_Net_Sales] <> 0 AND [Reporting_Month] = '" & repmonth & "' " & _
" GROUP BY TNS.[Division],TNS [Customer_Split],TNS.[Reporting_Month]"
With CurrentDb
Set qdf = CurrentDb.CreateQueryDef("TNS_QUERY", strSQL)
.Close
End With
DoCmd.RunSQL "Update TNS_QUERY Set Total_Net_Sales_in_EUR = Nz([Total_Net_Sales_in_EUR],0) + DSum('Total_Net_Sales_in_EUR','TNS_QUERY',Division = 'COMMON') " & _
" Where Division IN ('MC','AK')"