Solved

Column names on VBA SQL Query

Posted on 2011-09-15
2
192 Views
Last Modified: 2012-05-12
CurrentDb.Execute "SELECT INTER.OTCOMBO, INTER.DTCOMBO, INTER.TCOMBO, INTER.SERVICE, INTER.CLASS, INTER.MIN*0.65, INTER.LTL*0.65, INTER.[500]*0.65, INTER.[1M]*0.65, [INTER].[2M]*0.65, [INTER].[5M]*0.65, [INTER].[10M]*0.65, [INTER].[20M]*0.65 INTO Get65 FROM [INTER] WHERE INTER.TCOMBO=" & Chr(34) & termcombo & Chr(34) & " AND INTER.SERVICE=" & Chr(34) & [Forms]![Point2Point]![servicecombo] & Chr(34) & " ORDER BY INTER.CLASS", dbFailOnError

Open in new window


Hi,

Thank you for looking into this!

I have the above query. The problem is that when outputting, the query is not naming the columns. I've done internet research and could not find anything about what I am looking for.

What I really want is, lets take this part

[INTER].[20M]*0.65

^ Thats a column multiplication within the query (I am multiplying the column * 0.65) But when outputting, the column name comes up as "EXPR005"

Anyway to put in column name before the calculation?

Any help is much appreciated!

Shanan
0
Comment
Question by:Shanan212
2 Comments
 
LVL 7

Accepted Solution

by:
BusyMama earned 350 total points
ID: 36545199
[INTER].[20M]*0.65 AS <your column name here>

0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 150 total points
ID: 36545211
Seems you would want this ... one example shown:

CurrentDb.Execute "SELECT INTER.OTCOMBO, INTER.DTCOMBO, INTER.TCOMBO, INTER.SERVICE, INTER.CLASS, INTER.MIN*0.65 AS MyCalc1, INTER.LTL*0.65, INTER.[500]*0.65, INTER.[1M]*0.65, [INTER].[2M]*0.65, [INTER].[5M]*0.65, [INTER].[10M]*0.65, [INTER].[20M]*0.65 INTO Get65 FROM [INTER] WHERE INTER.TCOMBO=" & Chr(34) & termcombo & Chr(34) & " AND INTER.SERVICE=" & Chr(34) & [Forms]![Point2Point]![servicecombo] & Chr(34) & " ORDER BY INTER.CLASS", dbFailOnError
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question