Adding fiels in a query

Ben_Entrew

Registered User.
Local time
Today, 12:41
Joined
Dec 3, 2013
Messages
177
Hi all,

I want to group a table and show a new column. This new column should be the sum two other columns of the original table called TEST_FC.
Somehow it asks me for parameter with this code.

Your help is much appreciated.
Thanks in advance.

Regards,
Ben

Code:
Public Sub FC_QUERY()

Dim strSQL As String
Dim qdf As QueryDef
strSQL = "SELECT TEST_FC.[Division],TEST_FC.[Customer_Split],[two months FC] " & _
         " FROM TEST_FC " & _
         " WHERE [two months FC] = TEST_FC.[TNS 1 FC in TRY_SUM]+ TEST_FC.[TNS 2 FC in TRY_SUM] " & _
         " GROUP BY TEST_FC.[Division],TEST_FC.[Customer_Split],[two months FC]"
 
    With CurrentDb
                
                Set qdf = CurrentDb.CreateQueryDef("FC_QUERY", strSQL)
                .Close
    End With
End Sub
 
This new column should be the sum two other columns of the original table called TEST_FC.
Somehow it asks me for parameter with this code.

It looks like what you have is simply a column name that the query engine is unable to map to a physical column in the database table.

You never told the query you want a Summation performed and placed into that new column name.

I would suggest, pseudo code:
Code:
SUM([source column name here]) AS [two months FC]
 
Thanks Michael, it works now.
 
You are most welcome, Ben. I am pleased that the solution has been found so simply.
 

Users who are viewing this thread

Back
Top Bottom